I'm trying to write a chess game and find that I cannot find solutions to find a stalemate situation. I'm trying to google, but can't find anything. Is there a well-known algorithm or something?
Stalemate is a tie game. Also known as a Draw. 3 ways to stalemate: insufficient material (not enough firepower), no legal moves, and three-fold repetition. Well, there's one more – 50 king moves with no other legal moves – but this almost never occurs outside of scholastic tournaments.
It's automatic if you press the button and it is a threefold (or more) repetition. Me and aparently OP as well at one point or another were told that once the last piece before the King, was captured, the opponent has only 13 moves, 15 in my case, to checkmate, or it is a draw.
Just like with Checkmate, in a Stalemate the King cannot move—he has no Safe Squares. In fact, a Stalemate happens when there are no legal moves, just like Checkmate. The only difference is that since the King isn't threatened, the attacker can't claim a win and the game is declared a Draw!
There is no 15 move rule in standard chess.
Your move generator will be one of two different designs;
The former is better as it doesn't need post-processing.
A stalemate condition is simply one where there are no legal moves and the moving-side's king is not in check. A checkmate condition is one where there are no legal moves but the moving-side's king is in check.
In other words if you've figured out how to detect check and checkmate, you've already got everything necessary to detect stalemate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With