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

There’s something profound here about how the very natural conventions in Chess (“If you did that, you’d lose, so I’d rather we continue playing”) have redefined “valid” in a way that is surprisingly hard to re-implement with code.


You can make illegal moves in over the board chess, and sometimes it's advantageous to do so. E.g. In blitz chess an invalid move is an immediate loss. So, if you're going to lose anyway, you can make an invalid move hoping your opponent doesn't take the time to notice. One common one is to move your king next to your opponent's king, putting their king in check, if they don't call you on it, and don't move their king out of check, they lose. Unofficially, this is considered part of the game in blitz, but is considered unsportsmanlike in long games (where it's not an immediate loss).


From memory it wasn't so long ago that the laws of chess "allowed" you to play an illegal move to cause a checkmate (e.g. Qd1xf7 mate). Your opponent would say "hey that's an illegal move, take it back". You could then say "according to this rule, taking back illegal moves can only be done during a game, and according to this other rule, checkmate immediately ends the game".

Note that it can be discovered during a game that a move several turns ago was actually illegal, and the board should be returned to that position (and times adjusted). I had this happen to me once.


As a former USCF tournament director, I can say this is not true. Rule 13A - "The player who checkmates the opponent king, providing the mating move is legal, wins the game."

Additionally, there are many contradictory rules that can't all be applied, so there is a lot of room for the tournament director to apply the rules according to the spirit of the game rather than the word of the law.


The "checkmate immediately ends the game" rule gets really weird in 3-chess.


Is that... true? Are there tournament rules that say that? I'm not much of an OTB player, but this strikes me as somewhat against the spirit of the game. I will freely admit that I don't play blitz unless it's on a computer (I hate chess clocks) and computers don't allow illegal moves, but I would be very surprised if tournaments operated like this. Even small, local tournaments.


I remember reading about a serious tournament game where somebody castled twice. Nobody noticed during the game. I wonder how many computer databases allow that game to be entered.


That must have been Heidenfeld - Kerins, Dublin 1973.

https://www.chessgames.com/perl/chessgame?gid=2024861.

White castled short on move 10 and long on move 33. That didn’t help, though. White lost the game.

Also, it seems that site’s software doesn’t allow entering the full game.


Longer games go by FIDE's "Laws of Chess" which has a section 7 called "Irregularities" that indeed specifies the behavior if you accidentally knock over pieces or the game board falls over or you make an illegal move (moving away a piece that was keeping you from check etc).

Resolving irregularities does require your opponent to notice the irregularity and bring it to the attention of the referee.

Not sure about Blitz.


It always struck me as odd that the checkmate definition should be so (relatively) complicated. A much simpler definition is "you lose if the opponent captures your king". A checkmate is just a situation where you can't avoid getting your king captured. If someone doesn't notice their king is on check, then they could lose the next move. After you pass the beginner phase, this will almost never happen to you anyway, so most games will end the same way: checkmate or losing because of time.

When I was in school, we used to play blitz like that. You lost track of your king, boom, you're dead


I think that would make rules against castling through check inconsistent, and allowing castling through check would make the game pretty weird tbh


It is very easy to implement with code. Chess computers are some of the first well-known computer programs (see, for example, Deep Blue).

What is difficult is adapting chess's rules to this analog environment. It would be similarly difficult if you played this way with a real chess set in the real world, has nothing to do with code.


You don't actually have infinitely many moves available in analog chess since you can only click on a pixel. But while check should be doable in reasonable time, checkmate / stalemate would be expensive to compute since you have to check every possible move of yours (not just with the king, but with other pieces that could interpose as well) and then check every possible opponent's move in response to each of your moves to see if the king will be in check in the resulting positions.


You'll find that with some applied math you do not need to check every single possible move of the King.


Please elaborate.


you can’t represent the real plane on a computer. you can only have a limited amount of precision that effectively results in very dense grid, but a grid nonetheless


I don't think it can even be called a grid, as the gaps between points aren't the same length.


depends on your choice of floating point standard, you're right for the current IEEE one


This is a classic example of something that should be fixed point, not floating point. Just represent positions internally as an integer between 0 and some large maximum. You could use the number of screen pixels, or a larger value if you want to allow e.g. precise moves by zooming in.


If the gaps are all the same size, isn't it fixed point rather than floating point?


I mean, if your board has a fixed zoom level you have to fix a certain precision


are you able to represent it some place else?


what does this mean?


You stared real numbers are not representable, but specified “on computers”. Is there some medium they can be represented upon? Math papers is my only guess - but I read those on computers :)


*stated




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

Search: