Testing MinMax with alpha beta pruning and game strategy

I made a game (Connect-4) and used the MinMax algorithm with alpha-beta cropping for computer AI. What is a good way to verify the correctness of my alpha beta? I’m not sure of the correctness, sometimes when I play against my AI, he doesn’t make a game that will make the game last longer if it sees the loss deeper, and it is difficult to check things manually and with unit testing when it starts searching just litle deep ( 7-9 moves). How can this be fixed? (I know if alpha beta can crop what gives a more difficult victory if there is no way not to lose)

+4
source share
1 answer

Cutting alpha-beta in the well is only an optimization for the basic MiniMax algorithm (i.e. eliminating paths that, of course, would not be accepted by the optimal gaming enemy), so I would simply compare the results of the alpha-beta algorithm with a simpler MiniMax. Once they disagree, you have an error in one of two algorithms.

This simplifies the task of verifying the correctness of your MiniMax algorithm, and I cannot come up with any special tricks for this, but since this is a recursive function, you can write Unittests for all cases

+3
source

Source: https://habr.com/ru/post/1344371/


All Articles