r/ProgrammerHumor • • Apr 10 '23

Meme god why is coding chess so hard

Post image
67.4k Upvotes

1.8k comments sorted by

View all comments

289

u/smrtfxelc Apr 10 '23

Jesus christ. I'm right in thinking there are 10some big fucking number moves in chess, aren't I?

189

u/JonIsPatented Apr 10 '23

2 × 1046 possible board states, yes.

158

u/pappapirate Apr 10 '23

if you're coding it this way you would have to code every possible sequence of moves that result in each position, not just the positions.

76

u/ALiteralMermaid Apr 10 '23

Yeah you would literally have done the same amount of work as solving chess which is obviously not feasible

26

u/cloverasx Apr 10 '23

Yet.

19

u/[deleted] Apr 10 '23

It’s in the range of 10120 possible games which is larger than the number of atoms in the observable universe

12

u/GregTheMad Apr 10 '23

What if we use a binary tree? /s

4

u/cloverasx Apr 10 '23

10¹²⁰ ≠ ∞

7

u/barofa Apr 10 '23

Of course it is different than the laying eight

4

u/cloverasx Apr 10 '23

It just needs a nap; poor eight's all tuckered out.

4

u/[deleted] Apr 10 '23

I’m not saying it’s impossible but it would mean rethinking what we think it means to ‘solve’ a game. As it stands now chess is solved with 7 pieces on the board. It we are solving with the same method there literally isn’t enough matter in the universe to even come close to storing the information—you certainly can’t store a chess position with a single atom. The only way this works is with a breakthrough in quantum computing or something where we can access information without storing it in the traditional sense.

1

u/[deleted] Apr 11 '23

You're assuming we have to brute force it. What if we just find a smart way to deduce a strategy that guarantees white wins/black draws exists?

→ More replies (4)

2

u/meta-rdt Apr 10 '23

quite simply, there is no physical way for us to build a computer capable of storing the information required to compute something like that.

→ More replies (1)

0

u/[deleted] Apr 10 '23 edited Apr 10 '23

Also, I’m not sure you understand how big of a number this is

0

u/cloverasx Apr 11 '23

I'm quite certain I do.

0

u/[deleted] Apr 11 '23

And you think there are infinite atoms in the observable universe?

→ More replies (0)

3

u/aboinpallymusic Apr 10 '23

once OP finishes we'll do it

→ More replies (1)

6

u/l3rowncow Apr 10 '23

Well not with that attitude…

→ More replies (1)
→ More replies (3)

1

u/[deleted] Apr 10 '23

That's more half the amount of the protons in the observable universe

→ More replies (6)

1

u/Dye_Harder Apr 10 '23 edited Apr 10 '23

2 × 1046 possible board states, yes.

LEGAL board states? Or just ways pieces can be arranged on the board?

Is this a legal state?

https://imgur.com/a/5ZQou5w

also how many moves are allowed in these calculations? Most chess games have move limits, and many 'positions' will be impossible without huge move counts

2

u/JonIsPatented Apr 11 '23

2 × 1046 was the number calculated by people much smarter than me to be the number of board states that are theoretically reachable in a legal game.

1

u/Zut-Alors20 Apr 10 '23

Welp, best get started then

→ More replies (1)

3

u/Chaise91 Apr 10 '23

dumb question but how is chess actually programmed?

i would assume you code the rules and the beginning state and call it good.

→ More replies (1)

2

u/[deleted] Apr 10 '23

theres more chess games then atoms in the observble universe

1

u/Glesenblaec Apr 10 '23

Hopefully there's a multiverse so we can use those universes to calculate the perfect chess game in this one.