-
Notifications
You must be signed in to change notification settings - Fork 0
Piece Movements
Nick Slerts edited this page Dec 30, 2015
·
5 revisions
- The use of bitboards enables the use of bit operations for movement generation
>>n shifts bits n of bits to the right (keeps left most bit as is, use >>> to force 0)
<<n shifts bits n of bits to the left
n & m bits in n **AND** m that are both 1 are retained as 1s in result
n | m bits in n **OR** m that are both 1 are retained as 1s in result
n ^ m bits in n **OR** m that are 1 **BUT NOT BOTH** are retained as 1s in result (exclusive-or)
- 6 white: pawn, knights, bishops, rooks, queen, king
- 6 black: pawn, knights, bishops, rooks, queen, king
- 2 Files: A & H
- prevent bad pawn moves (File H -> File A)
- hold 1's for each bit contained in given file
- 4 Ranks
- 1 & 8
- used for pawn promotion
- hold 1's for each bit contained in given rank
- 4 & 5
- used for en passant
- hold 1's for each bit contained in given rank
- 1 & 8
- 1 empty spaces
- hold 1's for each bit that does not have a pc
- 1 for spaces with black pcs that white can capture
- bP, bN, bB, bR, bQ
- 1 for spaces with white pcs that black can capture
- wP, wN, wB, wR, wQ
- 1 for spaces of pcs that white can't capture
- wP, wN, wB, wR, wQ, wK, bK (because you should never capture the opposing king)
- 1 for spaces of pcs that black can't capture
- bP, bN, bB, bR, bQ, bK, wK (because you should never capture the opposing king)
- 1 for pawns
- incl: attack left + attack right + fwd move 1 space + fwd move 2 space
- 1 for knights
- 1 for bishops
- 1 for rooks
- 1 for queen
- 1 for king
- concatinate list of all possible moves
- maintain history of moves made
- search can be optimized by only looking between first and last destinations