oggy22 / BoardGames

A simple engine and end-tables for board games like chess, checkers and general tic-tac-toe (m,n,k-game) including connect 4. Heavy use of new C++ features like generator and concepts. Easy to add new engine and new game.
Apache License 2.0
2 stars 0 forks source link

Number of moves to mate integrated into minmax algorithm #22

Closed oggy22 closed 1 month ago

oggy22 commented 1 month ago

Here is the problem. When minmax sees a mate in 2 moves before seeing another mate in 1 move there is no mechanism by which it will prefer the 1-move mate over the 2-move mate. They both seem winning without distinction as they both score max on eval function. Corollary when analyzing a loosing position and mate is in horizon each move seems equally bad and based on the current implementation the first possible move will be chosen, instead of the one which maximally postpones the mate.

Solution is to decrement the max value for winning and increment min value for losing for each recursion level. Therefore a mate in two will score max-1 and mate in two will score max-2.