Thursday, August 15, 2013

Bahrs rule

One thing that makes iCE special compared to many other engines is the possession of endgame knowledge. It does not access external tablebases. It uses heuristics, rules and special evaluators to deal with specific endgames.

This is of course a wild field and there is always stuff that is still missing. One of the missing piece of chess knowledge is a draw rule in a KPPKP endgame with a blocked rook pawn and an outside passed pawn. Under certain conditions the defender can get a draw. It would be nice to see that statically in the evaluation without relying on search for that.

Bahrs rule can be tried when
  • the attackers locked rook pawn has not reached the 5th rank yet
  • the attackers king is next to its passed pawn
  • the defenders king is in front of the passed pawn or king
Draw as the white pawn has crossed the borderline
 
There is an additional condition. In order for the defender to draw the white passed pawn must have crossed the borderline already.

The borderline can be implemented with bitboards very easily so the conditions of Bahrs rule are fast to check. I extended Bahrs rule a bit so a few more draws can now be recognized.

This is the output (shortend) from iCE 1.0 for the above position. So until depth 16 it assigns a huge bonus to White because of the passed pawn. It needs 17 ply to realizes it is a draw and the score drops to 0.

iCE 1.0 v1619 x32 [2013.6.17]
position fen 8/6k1/8/p4KP1/P7/8/8/8 w - - 0 1
go
info depth 16 seldepth 18 time 0 nodes 1030 pv g5g6 g7g8 f5f6 g8h8 f6g5 h8g7 nps 1029999 score cp 408
info depth 17 seldepth 21 time 0 nodes 1655 pv g5g6 g7g8 f5f6 g8h8 f6g5 h8g7 nps 1654999 score cp 0  


The engine that knows about Bahrs rule sees this much earlier

iCE 2.0 v143 x32 [2013.7.23]
position fen 8/6k1/8/p4KP1/P7/8/8/8 w - - 0 1
go
info depth 1 seldepth 0 time 0 nodes 6 pv f5e5 nps 5999 score cp 319
info depth 2 seldepth 2 time 0 nodes 14 pv f5e5 g7g6 nps 13999 score cp 263
info depth 3 seldepth 3 time 0 nodes 47 pv f5e5 g7g6 e5e6 nps 46999 score cp 0


Now it only takes 3 ply to see it.

So iCE is now a bit smarter in deciding whether it should exchange into a KPPKP endgame or better not.
 

No comments:

Post a Comment