Is there an optimal depth in a game tree?

349 Views Asked by At

I'm working on this game engine which plays some board game, I implemented minimax with alpha beta pruning, and move ordering. Now when I play with other existing engines, everything looks fine. However, I found two subtle problems which I don't know what causes them, maybe I have some gap in my knowledge.

The first issue:

When I increase the depth of the search, intuitively I should get better results even if consumes more time, but in my case moving from depth 8 (winning) to depth 9 causes me to lose all the time, now if I increase it to 10 I suddenly win again. Keep in mind that I keep everything constant except the depth. At first I thought that maybe its because at depth 9 we find a promising move at first which the opponent can refute it easily, but then this could happen at every depth. So my question is what causes this weird behaviour? Is there an optimal depth, which if we go beyond could backfires?

The second issue: Its similar to move ordering but done to get the values of the next play to pick what to play. For example:

For every possible move starting from weakest move do: minimax(move)

Now since we have to go through all possible moves why having the strong moves first wins the game but if I started with the weakest moves loses the game. It doesn't make since we have to evaluate all possible moves anyway. What causes this behaviour?

1

There are 1 best solutions below

0
On

When I increase the depth of the search, intuitively I should get better results even if consumes more time, but in my case moving from depth 8 (winning) to depth 9 causes me to lose all the time, now if I increase it to 10 I suddenly win again.

Certainly sounds like a bug to me.

For every possible move starting from weakest move do:
    minimax(move)

You should always start from the strongest move in order to benefit from alpha-beta pruning

Now since we have to go through all possible moves

What about alpha-beta pruning? You do not have to go through all possible moves.