Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not quite - stalemate is no legal move whatsoever for any of your pieces, and checkmate is king is in check and no legal move stops check.


But given that a legal move by definition ends with the king not in check, the distinction often kind of goes away. In implementation terms, I think you basically have to just look at every possible move of every piece and see if any of them end without being in check.

Stalemate can and almost always does involve pieces that can't move because they would create check.


Yeah, that's true, I see what you're saying. I guess knowing the king is already in check allows for optimisations, since you have to either move the king, capture the attacker or block the line of attack, and nothing else is legal. And if you're double-checked you have to move the king, no matter what. As opposed to stalemate where you really do have to check the moves of every piece.


I guess that could be true if you have ready access to things like "the attacker" and "pieces that are capable of moving to block the line of attack".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: