sunfish icon indicating copy to clipboard operation
sunfish copied to clipboard

Sunfish doesn't use tempo in search.

Open NikolaiT opened this issue 9 years ago • 3 comments

My move: b5a5

  8 ♖ · ♗ · ♔ ♖ · ·
  7 ♙ ♙ · · · · ♜ ♜
  6 · · · · · · · ·
  5 ♕ · ♙ · · ♙ ♝ ·
  4 · · ♙ · · · · ·
  3 · · ♟ · · ♞ · ·
  2 ♟ · ♛ · · ♘ ♟ ·
  1 ♚ · · · · · · ·
    a b c d e f g h 


Your move: g7e7

  8 ♖ · ♗ · ♔ ♖ · ·
  7 ♙ ♙ · · ♜ · · ♜
  6 · · · · · · · ·
  5 ♕ · ♙ · · ♙ ♝ ·
  4 · · ♙ · · · · ·
  3 · · ♟ · · ♞ · ·
  2 ♟ · ♛ · · ♘ ♟ ·
  1 ♚ · · · · · · ·
    a b c d e f g h 


You won

There is no checkmate? Did sunfish give up because the evaluation was to low?

NikolaiT avatar Dec 28 '15 11:12 NikolaiT

You are correct, the simple UI in sunfish doesn't distinguish between 'mate found' and 'mate present'. This also means that sunfish may declare its victory, even when you aren't actually mate yet. When playing in xboard mode this is not much of a problem, since the real UI will usually decide when to end things.

What is more critical is that sunfish currently doesn't have the concept of tempo, or "mate in x". Hence it won't try to prolong dying or find the fastest mate. I worry that this might even cause it to never actually mate, since it can always find a slower way to do so. I haven't heard about this problem observed though, so maybe we got lucky, and iterative deepening sidesteps the problem.

thomasahle avatar Dec 29 '15 14:12 thomasahle

Sunfish is quite vulnerable to mates though, it doesn't bother with king safety. Here is a game of me vs him.

  1. d4 Nf6 2. c4 d5 3. cxd5 Bf5 4. Nc3 Nxd5 5. Qa4+ Bd7 6. Qb3 Nxc3 7. bxc3 Bc6 8. e4 Bxe4 9. Ba3 f5 10. Bc4 Bxg2 11. Bf7+ Mate in 1, Black resigned

Poryg1 avatar Mar 05 '16 18:03 Poryg1

That's a mate in 4 or 6 plies, depending on whether you consider sunfish' use of king capture for mate checking. I guess it just didn't think far enough to find it :-/. I added a test file avoid_mate.epd which can be used with python3 test.py tests/avoid_mate.epd to make sure it finds the correct move e6 in reasonable time. At least on my computer it finds it after a few seconds.

thomasahle avatar Jul 29 '16 18:07 thomasahle

Now it only takes 0.45 seconds.

thomasahle avatar Jan 08 '23 02:01 thomasahle