Last December I completed my very first chess engine as an introductory to C++. It's slower and weaker than I was hoping it would be, but I'm sure that I could optimize it quite a bit. Right now it probably plays at around a 1200-1300 Elo at depth 6 which is the deepest it can go comfortably.
Since all of you are basically chess engine gods, if anybody is up for it, I would love if somebody could skim through my code and point out any glaringly obvious mistakes (either with C++ or chess engine theory), I would much appreciate any kind of advice. I will admit that some parts of it is ugly and that I am very far from being proficient in C++ https://github.com/mp3259/Quokka
Here are a few questions I have based on the following information:
- I am using C++
- I am trying to get it to play at a respectable level (2000+)
- Piece locations & Move generation in my program is based off of the 120 indexed array method
Example: Move generation. using a empty preallocated 218 indexed array to store the generated moves, or just using a vector and dynamically adding moves.
2. How much of a speed difference does storing piece positions and movegen via bitboards make? Is the trade off in speed worth the time that it takes to understand and implement bitboards? What is the highest realistic level that it could play at using it's current method and instead focusing on optimizing the search/evaluation?
3. I'm trying to understand iterative deepening. Right now I have this kind of setup in my search function:
for (int i = 1; i <= depth; i++) {
do alpha beta algorithm to specified depth and assign it to score
print UCI info (score, depth, nodes, time)
print principal variation
}
Right now my engine does not follow the principal variation, which I'm pretty sure it needs to follow it in order to maximize speed when increasing the depth and redoing the alpha beta function.
Here is something kind of interesting which I noticed tinkering with the code above:
Running the search with the code above with the starting position, I can get to depth 7 in roughly 14 seconds. When I remove the for loop and just tell it to do alpha beta to depth 7 immediately, it takes the same amount of time if not more. What is the reasoning behind this? Shouldn't the looping method take longer because it's having to recalculate each time it increases the depth since it's not following the PV?