Here's a link to the github for the C++ engine.
I've played chess most of my life and I have a love for computers. So, it seemed natural to explore writting a chess engine. When diving deeper into the subject, I discovered even more aspects of chess engines, such as high performance computing, that increased my interest even move. Additionally, a chess engine is fairly easy to test and guage its strength, which means tweaking and improving is a simple process.
When starting to write a chess engine, most people, except Reptilians posing as humans, start with the 2D array implementation. It's the most natural considering a chess board is an 8x8 grid. There's nothing wrong with this solution, but it is slow. From the wisdom of other chess engine developers, a slow engine does not make a strong engine. So, be sure to abstract this code out properly so its easy to replace in the future. Or else, you might end up having to perform a rewrite. So I've forgone all of the slower implementations in favor of faster ones.
When trying to learn about chess engines, I didn't really find that much helpful material and code examples were awkward and hard to read. The best information I could find was from Chess Programming Wiki. Additionally, the Stockfish code is available for free. Stockfish is one of the best chess engines.
As mentioned before, I did not implement the 2D array board. In a short summary, we can examine what operations the computer needs to perform for simple common operations.
This is a common operation, we want to check a square to see if any piece is occupying that square. Assuming our position (a bit of a better name than board) is defined like this:
#include <cinttypes>
#include <array>
constexpr int32_t BOARD_WIDTH = 8;
const auto BOARD_HEIGHT = 8;
class Position {
private:
std::array<std::array<char, BOARD_WIDTH>, BOARD_HEIGHT>> squares;
}
I'll continue to add information to this over time.