# I'm making a chess engine.

Watch
Announcements
#1
Goal is just for it to make random moves atm, that seems complicated enough already. it's console based. All it can do atm is move a knight on a random walk and a pawn move forward until it's blocked. It selects randomly a piece and its move, then makes the move, it does this continually. Current issue is making sure the queen/rook/bishop doesn't travel through ally pieces. It's hard because the board consists of a 1d array, so there's lots of boring arithmetic, but thankfully I'm a boring person so will solve it eventually.

Anyone else done this? Or got any ideas of how I can detect blocking without using a squillion boolean variables?
0
#2
Can anyone help me with how to make sure pieces don't move through each other?
0
4 years ago
#3
(Original post by AYNTDIS)
Can anyone help me with how to make sure pieces don't move through each other?
You could set a moveable boolean field maybe for pieces?

if (moveable) {
do
}
0
3 years ago
#4
(Original post by AYNTDIS)
Goal is just for it to make random moves atm, that seems complicated enough already. it's console based. All it can do atm is move a knight on a random walk and a pawn move forward until it's blocked. It selects randomly a piece and its move, then makes the move, it does this continually. Current issue is making sure the queen/rook/bishop doesn't travel through ally pieces. It's hard because the board consists of a 1d array, so there's lots of boring arithmetic, but thankfully I'm a boring person so will solve it eventually.
Note that a "full" legal move generator is a fair bit harder than what you're trying so far.

You need to consider:

pawn moves (including the 2 squares on first move and en-passant).
castling (including not being allowed to castle through check)
some moves will be illegal because they will leave your king in check (not just king moves, but also moves of pieces that were blocking an attack on your king).

You might want to look at https://chessprogramming.wikispaces.com/#Basics

I fear it might be a bit over your head; an issue for a beginner writing a chess program is that most of the discussion is "how to do XYZ really quickly?", which is often overcomplicated when all you want is to be able to XYZ *at all*.

Another good place to start might be:

http://www.tckerrigan.com/Chess/TSCP/
0
X

new posts
Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### Poll

Join the discussion

#### Do you think receiving Teacher Assessed Grades will impact your future?

I'm worried it will negatively impact me getting into university/college (183)
43.78%
I'm worried that I’m not academically prepared for the next stage in my educational journey (48)
11.48%
I'm worried it will impact my future career (33)
7.89%
I'm worried that my grades will be seen as ‘lesser’ because I didn’t take exams (89)
21.29%
I don’t think that receiving these grades will impact my future (41)
9.81%
I think that receiving these grades will affect me in another way (let us know in the discussion!) (24)
5.74%