SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

Timeout with insufficient material should be a draw #292

Open lucasmeneghin opened 1 year ago

tezer2d commented 1 year ago

FIDE rules don't say "Timeout vs. Insufficient material" but "Timeout vs. No possible sequence of legal moves that would lead to checkmate". Strictly enforcing this rule would be impossible since it could require checking large numbers of moves, so usually most chess programs use shortcuts, e.g. https://lichess.org/faq#timeout

lucasmeneghin commented 1 year ago

What is the difference? Thats just the nomenclature Either way if white cant possibly mate black and black timeouts it should be a draw, not win for white.

tezer2d commented 1 year ago

if white cant possibly mate black and black timeouts it should be a draw

yes and as I said, proving that white can't possibly mate black requires looking at all possible sequences of legal moves. And that can be impossible to compute. So your feature request can't be implemented. Only a compromise could be implemented, e.g. assuming that it's enough to prove that white can't mate black in n moves, or assuming that if white has more than a king then checkmate is always possible

lucasmeneghin commented 1 year ago

Well, my feature request is exactly what can be implemented Timeout vs insufficient material is ALWAYS a case of timeout vs no legal sequence of moves, so it should always be a draw

icecream17 commented 1 year ago

Incidentally, while solving this problem very fast 100% guaranteed is mathematically impossible (for a general nxn board), it is possible to achieve 100% solving on an 8x8 board while being pretty much 100% very fast (see https://chasolver.org/)

(but realistically this issue would probably be solved by just checking the insufficient material case) (though the website does say it's ready to be used

lucasmeneghin commented 1 year ago

@SebLague tagging you so it gets special attention because this is basically a must for the tournament, since its base chess rules (unless you decide not to follow FIDE) I found the chasolver repo very helpful for understanding this problem better https://github.com/miguel-ambrona/D3-Chess/

The other edge cases dont necessarily need to be included because they are less likely to happen, even lichess and chess.com have different approaches sometimes The analyser also helps with this https://chasolver.org/analyzer.html

icecream17 commented 1 year ago

(pawnless insufficient material solver)

insufficient material:

insufficient material for one side (if the other side times out, then the side with insufficient material can't win so it is a draw)

SebLague commented 1 year ago

Thanks, I'll make sure the final tournament is run with this rule in place