Your program starts from assigning WINNING_POSITION
(win for your opponent, I suppose) to minRating
and then looping through the moves, trying to find the move with the maximum damage, minimizing minRating
.
When EvaluatePosition
returns LOSING_POSITION
than means this move leads to your opponent losing in every case, thus, search can be terminated and this move is considered the best move.
If there are no obvious LOSING_POSITIONS
, then your algorithm selects "best" move according to the static evaluation.