this post was submitted on 22 Feb 2024
696 points (96.4% liked)

Programmer Humor

32692 readers
354 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Venator@lemmy.nz 97 points 10 months ago (2 children)

Reminds me of how I made tic tac toe game for my first university assignment 🀣

[–] jaybone@lemmy.world 41 points 10 months ago (1 children)

That has a finite number of moves. And then you could possibly generate the code based on that finite set.

[–] Shard@lemmy.world 42 points 10 months ago (1 children)

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.

[–] Albbi@lemmy.ca 7 points 10 months ago (2 children)

Technically it's infinite, but that's because of a stalemate. You can keep repeating the same moves over and over.

[–] eatham@aussie.zone 13 points 9 months ago (2 children)

Stalemate is after 3 repeat moves, so no.

[–] my_hat_stinks@programming.dev 10 points 9 months ago

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.

[–] jaybone@lemmy.world 4 points 9 months ago

But it’s a state machine, and you could easily contrive scenarios for infinite moves, without stalemate.

[–] Scubus@sh.itjust.works 6 points 9 months ago

*finite, I'm assuming autocorrect gotcha

[–] eager_eagle@lemmy.world 40 points 10 months ago

"hey, as long as it works..."