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

2

u/fiealthyCulture Apr 10 '23

Hold on so how else do chess programs work tho? If not written like this ?

8

u/Verbina29 Apr 10 '23

Presumably, you would just write code for how each piece moves and players moving pieces.

7

u/JohnTheRedeemer Apr 10 '23

The chess board isn't recorded as a single state, each spot is a single cell that has its own state. Then the ai could interpret each of the individual states to decide the next move.

You only have to code for a cell's ability to maintain its own state (and movement to/from another cell) and its much easier to manage.

4

u/NotMyFirstUserChoice Apr 10 '23

If you have to write code like this, you're doing something terribly wrong.

2

u/Cxmu03 Apr 10 '23

Nah pretty sure stockfish works exactly like this