Chess technically has a finite number of moves. Although its a huge number and some have theorized its larger than the number of atoms in the known universe.
It’s not just repeated moves, a draw can be called if the board is in the same state 3 times at all during the game; if you get to the same position 3 times using different moves that still counts, even if it was a white move the first two times and a black move the third.
The game also ends after 50 moves with no captures or pawn moves so you can’t play indefinitely by just avoiding those board states. Interestingly those two moves also make it impossible to return to a previous board state (pawns can’t move backwards, extra pieces are never added) so if you’re enforcing both rules in code you can safely discard previous board states every time you reset the move counter.
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
Posts must be relevant to programming, programmers, or computer science.
No NSFW content.
Jokes must be in good taste. No hate speech, bigotry, etc.
Reminds me of how I made tic tac toe game for my first university assignment 🤣
That has a finite number of moves. And then you could possibly generate the code based on that finite set.
Chess technically has a finite number of moves. Although its a huge number and some have theorized its larger than the number of atoms in the known universe.
Technically it’s infinite, but that’s because of a stalemate. You can keep repeating the same moves over and over.
*finite, I’m assuming autocorrect gotcha
Stalemate is after 3 repeat moves, so no.
It’s not just repeated moves, a draw can be called if the board is in the same state 3 times at all during the game; if you get to the same position 3 times using different moves that still counts, even if it was a white move the first two times and a black move the third.
The game also ends after 50 moves with no captures or pawn moves so you can’t play indefinitely by just avoiding those board states. Interestingly those two moves also make it impossible to return to a previous board state (pawns can’t move backwards, extra pieces are never added) so if you’re enforcing both rules in code you can safely discard previous board states every time you reset the move counter.
But it’s a state machine, and you could easily contrive scenarios for infinite moves, without stalemate.
“hey, as long as it works…”