Search code examples
javaalgorithmminimaxalpha-beta-pruning

Alpha Beta and Minimax


I'm writing a minimax alpha beta algorithm in Java. What I did initially was create a minimax algorithm. This algorithm ALWAYS beat algorithm B, which I had also coded. Now I added Alpha beta pruning to this minimax algorithm and my algorithm always loses to algorithm B.

Is it possible that Alpha beta pruning made my algorithm worse? Or did I code it incorrectly?

And just for my curiosity; in a perfect world where I had implemented Alpha Beta correctly would I at least see my algorithm beat algorithm B 100% of the time if the minimax algorithm did?

Thank You.


Solution

  • You coded it incorrectly.

    There is (should be) no difference in outcome whether or not alpha-beta pruning is applied. It is merely a performance optimization where you avoid looking at options that are found quickly to be worse than other options already considered.