News for hackers. Stuff that matters.
Re:Analog Chess – pieces are not constrained to a grid by andrewfromx on Friday January 13, 2023 @11:56AM (#34370463)
"To win, you simply need to capture the opponent's king. This is mainly because stalemate is basically impossible, as the king can always move an infintesimal amount, and also because implementing check/checkmate would destroy the last ounce of sanity I have left."
Re:Analog Chess – pieces are not constrained to a grid by timerol on Friday January 13, 2023 @12:44PM (#34371121)
"Warning: This code is fucking awful.

Do not expect the code to be stable under any modifications, but you can try if you want I guess. Also there are barely any comments sorry. I am in Electrical Engineering and I like writing shitty code to piss off my Computer Science friends."

I appreciate this README's sense of humor

Re:Analog Chess – pieces are not constrained to a grid by bunnie on Friday January 13, 2023 @01:46PM (#34372097)
I can relate to this!
Re:Analog Chess – pieces are not constrained to a grid by knodi123 on Friday January 13, 2023 @05:07PM (#34374564)
lol, "Run the .py file with the highest number, because I can't figure out version control." Says the guy who posted it to github.
Re:Analog Chess – pieces are not constrained to a grid by felixworks on Friday January 13, 2023 @08:19PM (#34376215)
GitHub becoming Pastebin would be a hilarious turn of events.
Re:Analog Chess – pieces are not constrained to a grid by Kamq on Friday January 13, 2023 @10:41PM (#34377194)
It's kinda close already. I've gotten several pdfs of books by cloning repos.
Re:Analog Chess – pieces are not constrained to a grid by _Algernon_ on Saturday January 14, 2023 @09:02AM (#34380371)
You can upload files to github with drag and drop. They are not mutually exclusive.
Re:Analog Chess – pieces are not constrained to a grid by remram on Friday January 13, 2023 @09:27PM (#34376760)
The fact that he released it is awesome. So many people never released their code because "it's not ready" or "I want to clean it up" or whatever.

Fucking awful barely-functioning open source code is better than no code available, every time.

Re:Analog Chess – pieces are not constrained to a grid by tluyben2 on Saturday January 14, 2023 @03:33AM (#34378447)
My father (quantum mechanics) would sometimes submit awful but working code to Dijkstra without proofs just to piss him off. Dijkstra didn't like the looseness of the physics students when it came to software development, while physics students didn't like the software proofs for things in physics that were experimental and needed a 'quick' (nothing was 'quick' then compared to now of course) set of calculations/simulations and not waste time on writing formal proofs for them.
Re:Analog Chess – pieces are not constrained to a grid by bertil on Friday January 13, 2023 @12:45PM (#34371152)
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.
Re:Analog Chess – pieces are not constrained to a grid by cmeacham98 on Friday January 13, 2023 @01:54PM (#34372210)
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.

Re:Analog Chess – pieces are not constrained to a grid by ummonk on Friday January 13, 2023 @09:23PM (#34376733)
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.
Re:Analog Chess – pieces are not constrained to a grid by cmeacham98 on Friday January 13, 2023 @10:47PM (#34377216)
You'll find that with some applied math you do not need to check every single possible move of the King.
Re:Analog Chess – pieces are not constrained to a grid by ummonk on Saturday January 14, 2023 @06:23AM (#34379374)
Please elaborate.
Re:Analog Chess – pieces are not constrained to a grid by AstixAndBelix on Friday January 13, 2023 @02:13PM (#34372460)
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
Re:Analog Chess – pieces are not constrained to a grid by bspammer on Friday January 13, 2023 @04:27PM (#34374116)
I don't think it can even be called a grid, as the gaps between points aren't the same length.
Re:Analog Chess – pieces are not constrained to a grid by AstixAndBelix on Friday January 13, 2023 @05:00PM (#34374490)
depends on your choice of floating point standard, you're right for the current IEEE one
Re:Analog Chess – pieces are not constrained to a grid by ErikCorry on Friday January 13, 2023 @05:26PM (#34374758)
If the gaps are all the same size, isn't it fixed point rather than floating point?
Re:Analog Chess – pieces are not constrained to a grid by AstixAndBelix on Friday January 13, 2023 @06:26PM (#34375328)
I mean, if your board has a fixed zoom level you have to fix a certain precision
Re:Analog Chess – pieces are not constrained to a grid by rjmunro on Saturday January 14, 2023 @10:54AM (#34381231)
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.
Re:Analog Chess – pieces are not constrained to a grid by jakear on Friday January 13, 2023 @05:12PM (#34374626)
are you able to represent it some place else?
Re:Analog Chess – pieces are not constrained to a grid by AstixAndBelix on Friday January 13, 2023 @05:58PM (#34375083)
what does this mean?
Re:Analog Chess – pieces are not constrained to a grid by jakear on Saturday January 14, 2023 @05:02PM (#34384578)
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 :)
Re:Analog Chess – pieces are not constrained to a grid by jakear on Sunday January 15, 2023 @05:34AM (#34388393)
*stated
Re:Analog Chess – pieces are not constrained to a grid by gmiller123456 on Friday January 13, 2023 @03:45PM (#34373658)
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).
Re:Analog Chess – pieces are not constrained to a grid by distortedsignal on Friday January 13, 2023 @04:45PM (#34374318)
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.
Re:Analog Chess – pieces are not constrained to a grid by crdrost on Friday January 13, 2023 @04:58PM (#34374464)
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.

Re:Analog Chess – pieces are not constrained to a grid by kanzenryu2 on Friday January 13, 2023 @04:53PM (#34374412)
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.
Re:Analog Chess – pieces are not constrained to a grid by Someone on Friday January 13, 2023 @06:01PM (#34375117)
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.

Re:Analog Chess – pieces are not constrained to a grid by kanzenryu2 on Friday January 13, 2023 @04:51PM (#34374396)
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.

Re:Analog Chess – pieces are not constrained to a grid by shuntress on Friday January 13, 2023 @05:56PM (#34375052)
The "checkmate immediately ends the game" rule gets really weird in 3-chess.
Re:Analog Chess – pieces are not constrained to a grid by gmiller123456 on Friday January 13, 2023 @10:18PM (#34377068)
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.

Re:Analog Chess – pieces are not constrained to a grid by hasdha on Friday January 13, 2023 @10:06PM (#34377000)
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

Re:Analog Chess – pieces are not constrained to a grid by rtpg on Saturday January 14, 2023 @02:08AM (#34377997)
I think that would make rules against castling through check inconsistent, and allowing castling through check would make the game pretty weird tbh
Re:Analog Chess – pieces are not constrained to a grid by logicallee on Friday January 13, 2023 @01:12PM (#34371591)
In chess, you win when you are "about to" capture the opponent's king on your next move, which is called putting them in check, and there's no way for the other side to avoid it (block or move out of check).

So I've always found it very bizarre that if it's a player's move, but any possible move would put their own king in check, then it is a draw (rather than a loss).

This leads to a situation where one side can have almost no pieces left, perhaps only the king, but still somehow draw since the king can't move anywhere where it wouldn't be captured.

I imagine a king all by himself peeping his head out out for a place to move, but everywhere is covered by snipers, so, since he can't move anywhere without getting captured, despite being overwhelmed by enemy forces he yells out a la monte Python "So we'll call it a draw then!"

Re:Analog Chess – pieces are not constrained to a grid by hgsgm on Friday January 13, 2023 @01:30PM (#34371879)
It's because chess was invented by programmers, and stalemate means "the game is broken because there are no legal moves so it's impossible to continue", so we call it a draw.
Re:Analog Chess – pieces are not constrained to a grid by a_cardboard_box on Friday January 13, 2023 @01:52PM (#34372177)
You can also tell it's made by programmers because of the en passant "feature", which clearly only exists due to the programmers' incomplete implementation of the 2-square first move.
Re:Analog Chess – pieces are not constrained to a grid by barakm on Saturday January 14, 2023 @02:33AM (#34378120)
Your post and air quotes for “feature” are hella snide. In chess code, en passant is an edge case that takes a lot of code to cover, and not just some bug due to incompleteness.

Check yourself before you wreck yourself. And yes, check pun intended.

Re:Analog Chess – pieces are not constrained to a grid by pbhjpbhj on Friday January 13, 2023 @03:25PM (#34373399)
Maybe if you think of it in terms of the opposition falling to put you in check despite you only having a king left? Your army chased the opposing king to the forest but failed to defeat him, be gets to live out his days as a hermit. You are denied 'satisfaction'.

?

In my family, against my children, it's a running joke that I'll almost always fail to win, and stalemate them.

Re:Analog Chess – pieces are not constrained to a grid by bspammer on Friday January 13, 2023 @04:31PM (#34374156)
> the king can always move an infintesimal amount

I don't think this is true, it should be perfectly possible to cover the opponent's king's entire movement area with your pieces.

I'd love to see a version of this game that actually implements this :D

Re:Analog Chess – pieces are not constrained to a grid by gmoot on Friday January 13, 2023 @05:54PM (#34375039)
Then it's checkmate, not stalemate. For a stalemate you need a situation where the king is not in check, but there are no legal moves. It seems impossible in practice, if not in theory.
Re:Analog Chess – pieces are not constrained to a grid by Someone on Friday January 13, 2023 @06:13PM (#34375214)
You can have stalemate with two rooks or two bishops enclosing a square just large enough to contain the king.

A queen and a rook or bishop also can enclose a triangular area that is just large enough to contain the king.

(Talking of bishops: should this game require bishops to stay on squares of their starting colour?)

Re:Analog Chess – pieces are not constrained to a grid by mythas on Friday January 13, 2023 @10:47PM (#34377220)
How close to the king are they covering? .0000001 units? The king can move .00000009 units. You can always make a smaller real number.
Re:Analog Chess – pieces are not constrained to a grid by NineStarPoint on Friday January 13, 2023 @11:09PM (#34377316)
In theory yes. In practice, python uses floating point numbers for decimals so there is actually a minimum possible move and a finite number of allowed decimals.
Re:Analog Chess – pieces are not constrained to a grid by ehulinsky on Saturday January 14, 2023 @02:26AM (#34378080)
Also the game only has a resolution of 640x640 pixels, and you cant move the mouse a half pixel. But anyways, stalemate basically requires very precise positioning by the attacker, so it is VERY unlikely to actually happen, especially since they are trying to avoid stalemate.
Re:Analog Chess – pieces are not constrained to a grid by srcreigh on Saturday January 14, 2023 @02:42AM (#34378152)
The king can put himself in check too, so the defender would have to cooperatively allow checkmate (instead of capturing the other pieces)
Re:Analog Chess – pieces are not constrained to a grid by Someone on Saturday January 14, 2023 @11:48AM (#34381644)
Not if the distance is zero, and that’s mathematically doable and possible in IEEE floats, certainly for the two rooks or two bishops version.
Re:Analog Chess – pieces are not constrained to a grid by jjnoakes on Friday January 13, 2023 @11:58PM (#34377502)
> Talking of bishops: should this game require bishops to stay on squares of their starting colour?

Given how captured work and how you'd probably define "on a square" with white a bit of freedom (perhaps the center of the piece has to be within the square?) I doubt it'd matter much either way.

Re:Analog Chess – pieces are not constrained to a grid by masswerk on Friday January 13, 2023 @05:25PM (#34374748)
Chess meets Tablut / Hnefatafl…

(I guess, Vikings would appreciate the constraints arising from infinitesimal granularity movement.)