diff --git a/README.md b/README.md index e822a33..f666234 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,24 @@ This is the repo for a checkers AI project. * `build/runner` - When project is built it's compiled to the `runner` file -## Implementation Details -Here is an example of the bit board setup this project follows: +## (1) Implementation Details + +The project was implemented purely in c++. The decision to use c++ was made because bit manipulation in Java is unnecessarily difficult due to not having any definitive unsigned 32 bit integer primitive. C++ on the other hand contains a plethora of integer data types in the `cstdint` library. Two group members were also taking the networks course concurrently so socket programming in C wasn't an issue. + +### Bitboard Implenetation +Here is the bitboard layout that we utilized where each number corresponds to the bit index: ![bit board](/docs/bitboard.png) -This orientation allows all moves to be done with either a 7 bit or 1 bit rotation. +This orientation allows all moves to be done with either a 7 bit or 1 bit rotation. The entire board is then represented by three 32 bit integers: white pieces, black pieces, and kings. This is much more space-efficient than array implementations. + +Along with space saving there were other advantages. Using bit manipulation means there's no need to constantly index into any sort of data structure like in the array representation of a board, saving time. Another large advantage is that many of the heuristics can be done with bit masks. That, in combination with inlining done by modern c++ compilers, boils many of these calculations down to a few lines of machine code. + +### Search Implementation and Depth + +For search we stuck to a recursive minimax with alpha-beta pruning. This implementation can be seen in the `src/MinimaxSearch.cpp` file. This function, identical to the description in the textbook, allows the elimination of unnecessary search, cutting the ply factor by a quarter on average. + +We used a simple variable depth solution. We have a minimum and maximum search depth such that the minimum is always met and the search will continue to the maximum depth as long as there are jumps available. With this we could achieve a maximum ply of around 11 in a couple of seconds. The minimum depth of 5 ensured that pieces wouldn't hover around corners during endgame as 5 moves is often enough to encounter another piece which was combined with higher evaluation values on encounters rather than avoidance. ## Citations @@ -26,4 +38,4 @@ The vast majority of the project is personal work but there were some inspiratio * [Checkers Bitboard Tutorial](http://www.3dkingdoms.com/checkers/bitboards.htm#movegen) * [Compiler Friendly Bit Rotation in C](http://stackoverflow.com/questions/776508/best-practices-for-circular-shift-rotate-operations-in-c) * [Evolutionary-based heuristic generators](http://pdfs.semanticscholar.org/91c9/d140267f3b008d00b330b6b0e9182fa4b62e.pdf) -* [Strategy Game Programming](http://www.fierz.ch/strategy5.htm) \ No newline at end of file +* [Strategy Game Programming](http://www.fierz.ch/strategy5.htm) diff --git a/docs/bitboard.png b/docs/bitboard.png index d0e1aae..79d3a2c 100644 Binary files a/docs/bitboard.png and b/docs/bitboard.png differ