README finished
This commit is contained in:
31
README.md
31
README.md
@ -24,7 +24,8 @@ targets:
|
||||
- chessNoComputer: The user can play both sides in a GUI. Mainly added for testing the move
|
||||
generator.
|
||||
- findMagicNumber: finds Magic Numbers for the magic bitboard.
|
||||
- moveGenTest: tests the move generator
|
||||
- moveGenTest: tests the move generator,
|
||||
- genMoveConsts: produces constants to generate moves faster.
|
||||
|
||||
## Testing
|
||||
|
||||
@ -43,8 +44,30 @@ use bitwise operations to calculate information we need, really fast.
|
||||
The move generation of pseudo-legal moves (moves without considering whether the
|
||||
king is in check) is mostly straightforward. We pre-generate some data in
|
||||
`src/generateCode/moveConsts.c`, so that we can calculate the moves faster.
|
||||
For the king and the knight the moves are pre-generated because they can only
|
||||
possibly move to fixed target squares for one given source square. For the other
|
||||
pieces we pre-generated the distance, the piece can move in one given direction.
|
||||
|
||||
# sources
|
||||
For testing, if the king is in check, so we get legal moves, [magic
|
||||
Bitboards](https://www.chessprogramming.org/Magic_Bitboards) are used. This
|
||||
allows us to calculate really fast whether the king is in check compared to
|
||||
looping over all moves to see, if a piece can capture the king. Essentially we
|
||||
get the bitboard of all pieces and null all bits but the file and rank, the rook
|
||||
we want to the moves for, is on (or the relevant diagonals for the bishop). We
|
||||
can look up the moves by using this mask as a key of a hashmap. A hashing
|
||||
algorithm that multiplies with a so-called magic number and right shift, is used.
|
||||
The hashing is fast, and we can find magic numbers, so there are no hash
|
||||
collisions. To simplify the task of finding magic numbers, we use a different
|
||||
magic number for each square ([fancy magic
|
||||
bitboard](https://www.chessprogramming.org/Magic_Bitboards#Fancy)). The magic
|
||||
numbers for this engine are simply found by trying randomly generated one. The
|
||||
Implementation in `src/findMagicNumber.c` is based on ideas
|
||||
[there](https://www.chessprogramming.org/Looking_for_Magics#Feeding_in_Randoms).
|
||||
|
||||
https://www.chessprogramming.org/Magic_Bitboards
|
||||
https://www.chessprogramming.org/Looking_for_Magics
|
||||
For seraching the moves, we use a variant of [Alpha-Beta](https://www.chessprogramming.org/Alpha-Beta).
|
||||
Alpha-Beta is based on [minimax](https://en.wikipedia.org/wiki/Minimax) with an
|
||||
added upper and lower bound for the position score with makes it much faster
|
||||
than minimax.
|
||||
|
||||
The evaluation is currently simple because the only keeps track of the material
|
||||
and checkmate. Here is currently the most room for optimizations.
|
||||
|
||||
Reference in New Issue
Block a user