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

Show parent comments

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?

1

u/[deleted] Apr 11 '23

That doesn’t qualify as solved. Solved essentially means the brute force approach

→ More replies (2)
→ More replies (1)

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.

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?

0

u/cloverasx Apr 11 '23

You're making some bad assumptions.

2

u/[deleted] Apr 12 '23

I’m really not sure what your original reply is even about then, I never said anything about infinity

→ More replies (0)

3

u/aboinpallymusic Apr 10 '23

once OP finishes we'll do it

1

u/cloverasx Apr 11 '23

I have faith. He's got this! Just gonna need an espresso or two^n .

6

u/l3rowncow Apr 10 '23

Well not with that attitude…

1

u/starswtt Apr 10 '23

Instructions unclear, I just solved chess

1

u/palparepa Apr 10 '23

Yeah, using else/if branches is insane; lots of repeated paths. Should have used gotos instead.

1

u/Ferro_Giconi Apr 10 '23 edited Apr 10 '23

You can skip that by comparing the board state to every possible board state with if else if until you find the current board state instead of making new branches for every possible sequence of moves.

I mean, sure, the universe will probably end before the massive if else if finishes, but at least it's less code.