A good place to start your search for the game tree is the wiki chess programming . To your question about this movement: I think that two max functions are most common. The difference between the two maximum functions is that one returns only the score, and the other returns the score and the best move. The recursive call order will look like this:
maxWithBestMoveReturn(...)
There are some good pseudo-code documents for the Alpha Beta algorithm:
To your question in the comment: and math.max (alpha, score) or math.min (alpha, score) Is there an alpha boolean ?!
There is no alpha window bound in the alpha beta algorithm. The alpha value is updated with the new value. Because alpha and beta exchange a recursive call to the negamax function, the alpha variable refers to the beta variable in the next recursive call.
One note for the playerTurn variable: minimal or alpha-beta algorithm does not need this information. Therefore, I would provide information - who is next - to the Board-Structure. The findPossibleMoves and boardEval functions get all the necessary information from Board-Structure.
One note on the recursive interruption condition: if I understand your code correctly, then you will only have iterations == o . I think this means that the algorithm has reached the desired depth. But what if there are no possible steps left before the algorithm reaches this depth. Perhaps you should write the following:
vector<int> moves = findPossibleMoves(...); if (!moves.size()) return boardEval(...);
source share