Closed kerbals-repository closed 1 year ago
Let me just add a picture of the situation for those who don't speak fluent FEN ☺️ ![Uploading Screenshot_20220728-101819.png…]()
This is fixed in the latest sunfish:
~/repos/sunfish (nnue)$ ./sunfish.py
position fen r3n3/7Q/4pkp1/3p2P1/1p1P4/1P3PK1/r3q3/8 b - - 0 63
go
info depth 1 score cp 51 time 2 nodes 6 nps 2813 pv f6g5
info depth 1 score cp 140 time 3 nodes 8 nps 2557 pv f6g5
info depth 1 score cp 98 time 18 nodes 46 nps 2574 pv f6g5
info depth 1 score cp 115 time 19 nodes 49 nps 2579 pv f6g5
info depth 1 score cp 107 time 28 nodes 71 nps 2524 pv f6g5
info depth 2 score cp 112 time 43 nodes 102 nps 2390 pv f6g5
Sunfish claims that Qf2 is the best move in this position, although it is illegal.
r3n3/7Q/4pkp1/3p2P1/1p1P4/1P3PK1/r3q3/8 b - - 0 63
I therefore thought about changing the can_kill_king function to
`def can_kill_king(pos):
If we just checked for opponent moves capturing the king, we would miss
`
As far as I can see the function works as intended, but the pv function doesn't return any moves in some cases. So, it might be preferable if we also check the returned pv; if it's empty, we can use the prior pv (assuming it will return a pv at depth 1)