Jan 16, 2007

[Other] Null move reminder

I ran into trouble in the following position when trying out the transposition table:

It is white to move and obviously we want the engine to move the pawn.

With my current evaluation this position is evaluated to +100. Since white is a pawn up and I do not give bonuses for passed pawns or king positioning and such yet.

I do however give a bonus for a h/a-row pawn on the 6th rank, and a bigger bonus on the 7th rank. This is just a crude solution to help the engine realize advancing the pawns is a good thing if all else is equal. I will of course ellaborate a lot on this when I get to expanding the evaluation.

Anyway, in this position the engine should see the pawn getting to rank 6 in 5 plies. To rank 7 in 7 plies and to rank 8 in 9 plies.

But the evaluation at the different depths looked like this:
Ply Eval PV
1 100 Kb2
2 100 Kb2 Kg3
3 100 Kb2 Kg3 a3
4 100 Kb2 Kg3 a3 Kh2
5 100 Kb2 Kg3 a3 Kh2 Kc1
6 100 Kb2 Kg3 a3 Kh2 Kc1 Kg1
7 100 Kb2 Kg3 a3 Kh2 Kc1 Kg1 Kb2
8 100 Kb2 Kg3 a3 Kh2 Kc1 Kg1 Kb2 Kf2
9 120 a4 Kg3 a5 Kh2 a6 Kg1 Kb2 Kf2 a7
10 900 a4 Kg3 a5 Kh2 a6 Kg1 a7 Kf2 a8=Q Kg1
11 900 Kb2 Kg3 a4 Kh2 a5 Kg1 a6 Kf2 a7 Kg1 a8=Q
Clearly something is wrong.

The engine does not see the advance to 6th rank on the 5th ply nor does it see the queening of the pawn on the 9th ply, but on the 9th ply it does see the reaching of the 7th rank. Only at 10 ply does it see the queening.

After some testing and logical thinking I came to the conclusion null move pruning was the problem. And by disabling them I got this analysis instead:
Ply Eval PV
1 100 Kb2
2 100 Kb2 Kg3
3 100 Kb2 Kg3 a3
4 100 Kb2 Kg3 a3 Kh2
5 115 a4 Kg3 a5 Kh2 a6
6 115 a4 Kg3 a5 Kh2 a6 Kg1
7 120 a4 Kg3 a5 Kh2 a6 Kg1 a7
8 120 a4 Kg3 a5 Kh2 a6 Kg1 a7 Kf2
9 900 a4 Kg3 a5 Kh2 a6 Kg1 a7 Kf2 a8=Q
10 900 a4 Kg3 a5 Kh2 a6 Kg1 a7 Kf2 a8=Q Kg1
11 900 a4 Kg3 a5 Kh2 a6 Kg1 a7 Kf2 a8=Q Kg1 Kb2
Now it correctly spots the 6th rank advance on the 5th ply, and the queening on the 9th.

The reason for this is null-moves assume moving is an advantage. But since there is nothing black can do to improve his position it is not an advantage in this position.

What happens is when we try a null-move black can not improve his position and we assume the line is too strong. While it in fact is exactly the same (+100).

Null moves will work better in positions like this if we have more evaluations. Let us say black would get a higher score if he moved his king towards the pawn. If that was the case we would not cut off the line and the 'a4' move would not disappear in the cutoffs.

However as I said before, we should not use null moves in the end game even if we do have better evaluation (atleast not null moves in this form) since the risk of zugswang (explained earlier) is too great.

Well, I just wanted to share some insights I am getting from implementing the transposition table. It is really important to understand the search of your engine in order to get it working correctly. Especially how to use alpha and beta values.

No comments: