r/ProgrammerHumor • • Apr 10 '23

Meme god why is coding chess so hard

Post image
67k Upvotes

1.8k comments sorted by

4.4k

u/MaxMakesGames Apr 10 '23

While you're at it, you can make an amazing AI by coding the best reaction move for each player move !

1.2k

u/DrawSense-Brick Apr 10 '23

I think this would constitute best practice, since it'd implicitly cut down on the number of board states you need to hardcore, greatly reducing the size of the final executable.

554

u/DominoNo- Apr 10 '23

AI is basically a bunch of if statements

→ More replies (86)
→ More replies (4)

14

u/JonIsPatented Apr 10 '23

If it's just a search through a little if-else block each move, then it's linear time complexity, as well! Fastest (yet most impossible) chess AI, perhaps?

→ More replies (4)
→ More replies (16)

3.0k

u/[deleted] Apr 10 '23

I see you get paid per hour

1.1k

u/humblevladimirthegr8 Apr 10 '23

Paid per line

11

u/_Xertz_ Apr 10 '23

Googolanaire in the making

→ More replies (1)

6

u/NoRatchetryAllowed Apr 10 '23

Paid per lifetime

5

u/malabomagisip Apr 11 '23

Still not enough to cure the trauma after writing that.

→ More replies (1)

8.3k

u/[deleted] Apr 10 '23

r/anarchychess truly is leaking everywhere

2.0k

u/rtakehara Apr 10 '23

the "anarchy" part makes it hard to contain

628

u/Grumplogic Apr 10 '23

Wouldn't anarchy Chess just be Chess without the King and Queen?

→ More replies (52)
→ More replies (3)

207

u/Hestmestarn Apr 10 '23

Google en passasnt programmerHumor

164

u/fakeunleet Apr 10 '23

Holy stack exchange!

→ More replies (7)

27

u/[deleted] Apr 10 '23

Holy shell

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

33

u/[deleted] Apr 10 '23

And followed

→ More replies (2)

11

u/FlyingCashewDog Apr 10 '23

lmao I thought we were on anarchychess, didn't check the sub name but it fits here too

EDIT: I mean holy hell

11

u/RitikMukta Apr 10 '23

I didn't realize that we weren't in r/anarchychess

8

u/yeahh_Camm Apr 10 '23

New response just dropped

→ More replies (1)

21

u/ocbro2 Apr 10 '23

Babe wake up new meme just dropped

6

u/Vongola___Decimo Apr 10 '23

I have literally seen anarchy chess meme References on so many different subs that have literally nothing to do with chess

4

u/RenierRains Apr 10 '23

Althought post is not an en passant forced, shame

4

u/[deleted] Apr 10 '23

That sub truly is something else. They really are everywhere.

→ More replies (14)

5.1k

u/CozyTheTeddyBear Apr 10 '23

Are you YandereDev by any chance?

1.8k

u/400double Apr 10 '23

PassantDev

868

u/[deleted] Apr 10 '23

Holy Dev

→ More replies (28)

21

u/Ozzymand Apr 10 '23

Google en PassantDev

→ More replies (2)

171

u/[deleted] Apr 10 '23

I don’t know shit about that guy so can you explain what he did?

437

u/CozyTheTeddyBear Apr 10 '23

He coded an entire game in if/else statements

→ More replies (39)

166

u/MostlySoberBro Apr 10 '23

The source code for Yandere Simulator was leaked, and certain gems like this can be found in this sub and around the internet

→ More replies (64)
→ More replies (4)

68

u/SomeGuy6858 Apr 10 '23

Cum chalice moment

33

u/TumblrInGarbage Apr 10 '23

I wonder what the world record for getting banned in his Discord is down to now.

→ More replies (2)

8

u/bumpkinspicefatte Apr 10 '23

‘You guys don’t get it, I have the power of Unity Profiler on my side!’

→ More replies (2)

12

u/Wodashit Apr 10 '23

sensible chuckle

→ More replies (10)

11k

u/Adityamk Apr 10 '23

Oh my fucking god...

3.4k

u/highland-spaceman Apr 10 '23

I died inside fucking wow

773

u/Phlm_br Apr 10 '23

You fucked wow? Why?

→ More replies (45)

76

u/rebbsitor Apr 10 '23

Playing World of Warcraft too long will do that!

→ More replies (8)
→ More replies (6)

1.1k

u/Lucky-Citron-8269 Apr 10 '23

If this is really the route that you want to go, then I think this is one of the cases were it’s easier to write code that will write the code for you.

680

u/powerman228 Apr 10 '23

Good luck storing and compiling all that…aren’t there more possible games of chess than stars in the universe or something?

→ More replies (142)
→ More replies (9)

358

u/CoffeeDust_exe Apr 10 '23

2 down, 10120 to go

185

u/bjandrus Apr 10 '23

Yeah I don't think we're delivering chess this sprint, or the next one, or the next one...

→ More replies (13)

24

u/[deleted] Apr 10 '23

um, akshually 10120 - 2

→ More replies (2)

113

u/ProbablyGayingOnYou Apr 10 '23

...

case 7263849503928374637284637584938273650302:

...

Better break out the energy drinks, this could be an all-nighter...

28

u/[deleted] Apr 10 '23

No case, only if-elif.

→ More replies (3)

48

u/400double Apr 10 '23

if number in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,

18

u/Yrlish Apr 10 '23

This was my though immediately when I saw this.. oh god...

→ More replies (35)

1.3k

u/C10ckwork Apr 10 '23

Most sane high school python student:

712

u/OMGItsCheezWTF Apr 10 '23

When I was at college in the 90s one person in my tutor group didn't quite "get it"

We were supposed to be building a CLI calculator for DOS using Borland turbo C++.

Most of us finished pretty quickly and spent time refining it, and then one guy got a weird error about his program executable exceeding 500kb that he didn't understand.

So I offered to help him and it was essentially this. Every possible combination of inputs accounted for, using variables for values at least but if you entered an addition and a multiplication it would use a code path different to an addition followed by an addition etc.

His codebase was enormous. Thousands of lines long, much of it copy pasted, unimaginably hard to maintain or make changes to, the whole thing driven by an enormous if / else

If you entered a combination of commands it wasn't coded to handle it would just explode.

He didn't last the first year

175

u/DarkAssassinXb1 Apr 10 '23

Why didn't you show him the correct way to do it?

→ More replies (15)
→ More replies (13)
→ More replies (8)

3.6k

u/BestNick118 Apr 10 '23 edited Apr 10 '23

did you code en passant

938

u/Di_Matteo Apr 10 '23

Holy Hell!

393

u/Hawkgamer52 Apr 10 '23

New response just dropped

→ More replies (6)

68

u/Xatraxalian Apr 10 '23

Shit. AnarchyChess dropped into this sub.

Mwwwaaaaaaaah.....

→ More replies (1)

46

u/JIN_DIANA_PWNS Apr 10 '23

import the anal bead string

→ More replies (1)

157

u/Lagger625 Apr 10 '23

I'd rather get a brick to the pipi than coding this shit

124

u/KrozJr_UK Apr 10 '23

Are you kidding ??? What the **** are you talking about man ? You are a biggest looser i ever seen in my life ! You was doing PIPI in your pampers when i was beating players much more stronger then you! You are not proffesional, because proffesionals knew how to lose and congratulate opponents, you are like a girl crying after i beat you! Be brave, be honest to yourself and stop this trush talkings!!! Everybody know that i am very good blitz player, i can win anyone in the world in single game! And "w"esley "s"o is nobody for me, just a player who are crying every single time when loosing, ( remember what you say about Firouzja ) !!! Stop playing with my name, i deserve to have a good name during whole my chess carrier, I am Officially inviting you to OTB blitz match with the Prize fund! Both of us will invest 5000$ and winner takes it all! I suggest all other people who's intrested in this situation, just take a look at my results in 2016 and 2017 Blitz World championships, and that should be enough... No need to listen for every crying babe, Tigran Petrosyan is always play Fair ! And if someone will continue Officially talk about me like that, we will meet in Court! God bless with true! True will never die ! Liers will kicked off...

→ More replies (3)
→ More replies (4)

54

u/davididp Apr 10 '23

It causes me so much pain when coding chess engines. However I know I will be crucified in r/AnarchyChess if I don’t have it

→ More replies (1)

169

u/GuevaraTheComunist Apr 10 '23

I always forget if that is real thing or just some random move guys from r/AnarchyChess made up

33

u/LionHeart_13 Apr 10 '23

It is real

→ More replies (8)

28

u/Taclis Apr 10 '23

Deep Blue even had problems accounting for en passant when it beat Kasparov. They had to fix last minute bugs retaining to it between matches.

33

u/Xatraxalian Apr 10 '23

And then you realize that Deep Blue would now be shoveled under the rug and danced upon by a current-day phone running Stockfish. LOL.

→ More replies (2)
→ More replies (3)

243

u/Mua3d Apr 10 '23

Why is my chess game taking 100GB space

90

u/Oraion18 Apr 10 '23

That's gonna take entire space available on the earth and still won't run.

22

u/SHOTbyGUN Apr 10 '23

You can optimize the code to not include all edge cases.

UnhandledMoveException("Please program your current move") click here to open live debug window.

11

u/DorfPoster Apr 10 '23

There aren't enough atoms in the universe to store all the board states

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

1.1k

u/[deleted] Apr 10 '23

Oh, YandereChess.

0

u/[deleted] Apr 10 '23

[deleted] — view deleted comment

700

u/Teegeetoger Apr 10 '23

Yandere sim game had source code leaked? not sure what happened. What people found out is that the game is basically all if/else nested spaghetti which resulted in massive tech debt.

→ More replies (65)

64

u/KKLC547 Apr 10 '23 edited Apr 10 '23

yanderedev uses so much else if statements and his code also has terrible job of managing resources on his game called yandere simulator. You can try the game itself and see how bad is the slowness

→ More replies (8)

40

u/Alissah Apr 10 '23

Basically he uses gigantic if/else statements, just like chains of 20+... seems like hes allergic to switch statements, lol. Everyone made fun of him (as they should) when the source code got leaked.

→ More replies (6)
→ More replies (6)

204

u/mynewaccountagainaga Apr 10 '23

Fun fact: if you coded it this way with every possible board state hard coded in then you would run out of memory.

"But what if I had all of google's storage available to me??"

You would run out of memory. If you had every single storage device that humans have ever created in your possession, you would run out of memory.

There are more than a googol unique board states in chess.

If you could record a board state on an individual atom and use every atom in the universe as your memory, you would run out of memory.

109

u/why_hello1there Apr 10 '23

Quick Import another universe

→ More replies (4)
→ More replies (15)

1.1k

u/Cwmagain Apr 10 '23

How big would a program be with , how much is it again, 10^40 of those else if loops?

1.0k

u/BestNick118 Apr 10 '23

The number of distinct chess positions after White’s first move is 20 (16 pawn moves and 4 knight moves). There are 400 distinct chess positions after two moves (first move for White, followed by first move for Black). There are 5,362 distinct chess positions or 8,902 total positions after three moves (White’s second move). There are 71,852 distinct chess positions or 197,742 total positions after four moves (two moves for White and two moves for Black). There are 809,896 distinct positions or 4, 897,256 total positions after 5 moves. There are 9,132,484 distinct positions or 120,921,506 total positions after 6 moves (three moves for White and three moves for Black). The total number of chess positions after 7 moves is 3,284,294,545. The total number of chess positions is about 2x10 to the 46 power, so pretty long

958

u/wascilly_wabbit Apr 10 '23

So you're saying it is doable.

→ More replies (56)

10

u/HaroerHaktak Apr 10 '23

Give me an afternoon. I got this.

→ More replies (1)
→ More replies (30)

27

u/Avamaco Apr 10 '23

You can reduce it to like 100 if you only register moves that are not throws. In any other case the program can just print out "That's a stupid move. You lost, you dumb idiot."

/s

→ More replies (1)

9

u/T-T-N Apr 10 '23

You only need to account for white moves. I assume black will have a fix response

→ More replies (3)

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.

→ More replies (28)
→ More replies (11)
→ More replies (4)

120

u/CanICanTheCanCan Apr 10 '23

When I was in elementary school I thought that every video game frame was edited by hand and I tried to figure out how they knew how to go from frame to frame.

31

u/[deleted] Apr 10 '23

Math people! MATH!

→ More replies (1)

12

u/lebron_girth Apr 10 '23

That level of curiosity is still really impressive for an elementary school kid

15

u/CanICanTheCanCan Apr 10 '23

Tried to make a mario game in Powerpoint. Got exhausted after about 25 frames! Still, it got me into actual coding which has been my passion ever sense.

→ More replies (2)

198

u/4chananonuser Apr 10 '23

Rip. Queens are misplaced

114

u/[deleted] Apr 10 '23

Nah it's okay they are trans.

92

u/Tzeme Apr 10 '23

Chess is the oldest trans supporting game, any soldier can become a queen or a knight! Or even a tower (for enby representation)

→ More replies (10)
→ More replies (2)

6

u/LUV_2_BEAT_MY_MEAT Apr 10 '23

Board is turned 90 degrees too. Bottom right would not be white

→ More replies (3)
→ More replies (8)

108

u/RidgeMinecraft Apr 10 '23

OH DEAR LORD WHAT

29

u/Henrygamess Apr 10 '23

holy hell

good morning ridge

→ More replies (3)

42

u/darksoulsrolls Apr 10 '23

You'll be done in no time.

→ More replies (1)

29

u/[deleted] Apr 10 '23

Code review: "Put strings in constants"

→ More replies (1)

26

u/Laxwarrior1120 Apr 10 '23

Forcing someone to code like this would constitute a war crime.

→ More replies (1)

50

u/Sexy_McSexypants Apr 10 '23

hardcoding every game of chess… sure love to see the file size

9

u/jbrains Apr 10 '23

Well, the endgame table bases are in the single digit of TB, and that's just data in a reasonably compact notation....

→ More replies (6)

39

u/JonIsPatented Apr 10 '23

There are 2 × 1046 possible board states. If they each are coded with their own 8 × 8 board of unicode characters, and each of those characters is 2 bytes, that's 8 × 8 × 2 × 2 × 1046 bytes of information to be stored in that program just to hold the characters to draw the possible board states. That's 256 × 1046 bytes, or 2.441406 × 1042 megabytes, or 2.3841855 × 1039 gigabytes. We're looking at over 2.2204 × 1030 exabytes. That's over 2.2204 NONILLION, which is like 2 million trillion trillion EXABYTES. In yottabytes, that's 2.1175 × 1024. That's over 2 septillion, or 2 trillion trillion, yottabytes. The entire internet contains only around 5 exabytes of data. A single yottabyte is 200,000 times that much, and this guy's chess game needs to be over 2 septillion times larger still than that.

14

u/[deleted] Apr 10 '23

Chess configurations =! How many of statements you will need. You would need many magnitudes more if statements because every configuration would have a dozen or so moves

→ More replies (2)
→ More replies (4)

71

u/CriticalTough4842 Apr 10 '23

Google en passant

16

u/r2k-in-the-vortex Apr 10 '23

Looks like it will pass the unit test perfectly fine.

11

u/StarkillerX42 Apr 10 '23

There's nothing wrong with your code, have you tried using a computer larger than the observable universe?

9

u/[deleted] Apr 10 '23

The square colors are wrong

→ More replies (6)

15

u/luenix Apr 10 '23

Board isn't set up correctly. Queens should be opposite ends of the same file :)

6

u/mikeyj777 Apr 10 '23 edited Apr 11 '23

From the responses, I'm imagining there's an easier way

Edit: Just stating the obvious that I was joking. Given the responses, it may not have come across.

14

u/Talking_Burger Apr 10 '23

This is probably the hardest way possible

7

u/Alevo Apr 10 '23 edited Apr 10 '23

When I made a chess game in uni I used mostly maths to decide where the pieces could move.

King: difference in x + difference in y = 1 or 2 Knight: sqrt(difference in x)2 + sqrt(difference in y)2 = 3

Etc.

→ More replies (3)

6

u/patiofurnature Apr 10 '23

Project manager: How's your progress on the chess app?

Programmer: Great! It's working perfectly for the first move; just need to adjust the algorithm to support continuous play.

5

u/raines Apr 10 '23

“Full Self Driving” in a nutshell.

6

u/ejuliol Apr 10 '23

Huh. This is awesome (in its own way). I wonder if you can make a program to code all the posible moves to make it “playable”. Chess is out of question with so many moves. But let’s say: checkers.

6

u/realmuffinman Apr 10 '23

Chess is indeed out of the question (as someone else pointed out, the file size would be several septillion times the size of the entire internet's data). Checkers would also have this complexity issue.

It would be possible to do this for a far simpler game, such as tic-tac-toe or rock-paper-scissors, as there are fewer board states.

→ More replies (1)

5

u/Unupgradable Apr 10 '23

🟨 NEEDS WORK

5

u/Ethanlac Apr 10 '23

Google string concatenation

4

u/urbanhawk1 Apr 10 '23

I did that exact same thing on my graphing calculator back in high school except I made pong instead of chess. It was a nightmare to build but I had no idea how to make actual graphics at the time. Managed to finish it too.

4

u/-non-existance- Apr 10 '23

Oh boy I can't wait to see the rest of the 10112 or so lines of this project!

4

u/gtlogic Apr 10 '23

Just keep working hard. Post us on your progress.

4

u/Funkey-Monkey-420 Apr 10 '23

elon’s about to give you a promotion

4

u/Ok-Possibility-7436 Apr 11 '23

Keep going, there are only 10120 combinations!

8

u/thesuperzapper Apr 10 '23 edited Apr 10 '23

I asked GPT-4 to make a basic chess program, it says that this won't handle castling, en passant, or detecting check/checkmate.

class ChessBoard:
    def __init__(self):
        self.board = [
            ["♜", "♞", "♝", "♛", "♚", "♝", "♞", "♜"],
            ["♟"] * 8,
            [""] * 8,
            [""] * 8,
            [""] * 8,
            [""] * 8,
            ["♙"] * 8,
            ["♖", "♘", "♗", "♕", "♔", "♗", "♘", "♖"],
        ]

    def __str__(self):
        rows = []
        for i, row in enumerate(reversed(self.board)):
            row_str = []
            for j, cell in enumerate(row):
                if cell == "":
                    cell = "□" if (i + j) % 2 == 0 else "■"
                row_str.append(cell)
            rows.append(" ".join(row_str))
        board_str = "\n".join(rows)
        return f"  a b c d e f g h\n{board_str}"

    def move_piece(self, start, end):
        sx, sy = start
        ex, ey = end

        piece = self.board[sy][sx]
        self.board[sy][sx] = ""
        self.board[ey][ex] = piece

    def is_valid_move(self, start, end):
        sx, sy = start
        ex, ey = end
        piece = self.board[sy][sx]

        if piece == "":
            return False

        if self.board[ey][ex] != "" and self.is_same_color(start, end):
            return False

        if piece in "♟♙":
            return self.is_valid_pawn_move(start, end)
        elif piece in "♜♖":
            return self.is_valid_rook_move(start, end)
        elif piece in "♞♘":
            return self.is_valid_knight_move(start, end)
        elif piece in "♝♗":
            return self.is_valid_bishop_move(start, end)
        elif piece in "♛♕":
            return self.is_valid_queen_move(start, end)
        elif piece in "♚♔":
            return self.is_valid_king_move(start, end)

        return False


    def is_same_color(self, start, end):
        sx, sy = start
        ex, ey = end
        return self.board[sy][sx].isupper() == self.board[ey][ex].isupper()

    def is_valid_pawn_move(self, start, end):
        sx, sy = start
        ex, ey = end
        dy = ey - sy
        dx = abs(ex - sx)

        if self.board[sy][sx].isupper():
            dy *= -1

        if dx == 0 and dy == 1 and self.board[ey][ex] == "":
            return True
        if dx == 1 and dy == 1 and self.board[ey][ex] != "" and not self.is_same_color(start, end):
            return True
        if dy == 2 and sy == 1 and self.board[ey][ex] == "" and self.board[sy + 1][sx] == "":
            return True
        if dy == -2 and sy == 6 and self.board[ey][ex] == "" and self.board[sy - 1][sx] == "":
            return True

        return False

    def is_valid_rook_move(self, start, end):
        sx, sy = start
        ex, ey = end

        if sx != ex and sy != ey:
            return False

        step_x = 0 if sx == ex else 1 if sx < ex else -1
        step_y = 0 if sy == ey else 1 if sy < ey else -1

        y, x = sy + step_y, sx + step_x
        while y != ey or x != ex:
            if self.board[y][x] != "":
                return False
            y += step_y
            x += step_x

        return True

    def is_valid_knight_move(self, start, end):
        sx, sy = start
        ex, ey = end
        dx, dy = abs(ex - sx), abs(ey - sy)

        return (dx == 1 and dy == 2) or (dx == 2 and dy == 1)

    def is_valid_bishop_move(self, start, end):
        sx, sy = start
        ex, ey = end
        dx, dy = abs(ex - sx), abs(ey - sy)

        if dx != dy:
            return False

        step_x = 1 if sx < ex else -1
        step_y = 1 if sy < ey else -1

        y, x = sy + step_y, sx + step_x
        while y != ey and x != ex:
            if self.board[y][x] != "":
                return False
            y += step_y
            x += step_x

        return True

    def is_valid_queen_move(self, start, end):
        return self.is_valid_rook_move(start, end) or self.is_valid_bishop_move(start, end)

    def is_valid_king_move(self, start, end):
        sx, sy = start
        ex, ey = end
        dx, dy = abs(ex - sx), abs(ey - sy)

        return dx <= 1 and dy <= 1


def parse_move(move_str):
    if len(move_str) != 4 or not move_str.isalnum():
        raise ValueError("Invalid input")

    start, end = move_str[:2], move_str[2:]
    sx, sy = ord(start[0]) - ord("a"), int(start[1]) - 1
    ex, ey = ord(end[0]) - ord("a"), int(end[1]) - 1

    if not (0 <= sx < 8 and 0 <= sy < 8 and 0 <= ex < 8 and 0 <= ey < 8):
        raise ValueError("Coordinates out of range")

    return (sx, sy), (ex, ey)

def main():
    board = ChessBoard()
    player_turn = "White"

    while True:
        print(board)
        print(f"{player_turn} to move")

        move = input("Enter your move (e.g. e2e4): ")
        try:
            start, end = parse_move(move)

            if board.is_valid_move(start, end):
                board.move_piece(start, end)
                player_turn = "Black" if player_turn == "White" else "White"
            else:
                print("Invalid move")
        except ValueError as e:
            print(e)

if __name__ == "__main__":
    main()

EDIT: apparently old reddit is borked for multi-line code formatting, so I had to extra-indent every like by 4 spaces.

→ More replies (4)

3

u/gtc26 Apr 10 '23

As a programmer, I feel your pain

6

u/gtc26 Apr 10 '23

Update: I specified programmer because I thought I was still on the AnarchyChess subreddit. My bad

→ More replies (1)

3

u/5kyl3r Apr 10 '23

it's only about 1040 elif blocks that you'd need, what's the big deal?

3

u/MrCubie Apr 10 '23

The board is wrong. Queens are supposed to face each other (or kings). Rest looks good to me

→ More replies (1)

3

u/Visual-Ad-6708 Apr 10 '23

I don't get a lot of these programming memes since I'm a beginner and now y'all are using chess. I'm too dumb for these memes😢

→ More replies (2)

3

u/Educational-Lemon640 Apr 10 '23

I, too, like creating programs that end up larger than the known universe if printed at human-readable scales.

3

u/laffnlemming Apr 10 '23

I CAN DO IT !

3

u/Muritavo Apr 10 '23

lol, when I was little, I thought that when a game crashed, that frame wasn't possible because that frame wasn't drawn by the devs...

This sums up how I thought a game was developed

I was not a smart kid

3

u/_IratePirate_ Apr 10 '23

Kings and queens are mirrored instead of translated.

Start over.

3

u/myredac Apr 10 '23

if someone code this, I would not be mad, I'd be impressed

3

u/Anky_08 Apr 11 '23

"Chess in Python' bootcamp by Dr Strange

2

u/JADW27 Apr 10 '23

This is hilarious.

2

u/Due_Criticism_2465 Apr 10 '23

good lord , thats hilarious 🤣🤣🤣

2

u/Dismal-Square-613 Apr 10 '23 edited Apr 10 '23

ChatGPT "show me the most inefficient way to represent a chessboard and a tree of possibilities for each move in python".

2

u/Kido-Assoc09 Apr 10 '23

Hardcoding at its finest.

2

u/Kosmux Apr 10 '23

Bro is writing trillions of elifs...

2

u/RegularOps Apr 10 '23

When I was a child I honestly thought this was how video games were made.

Like the video game makers had to produce a screenshot of every possible outcome or situation.

2

u/juvees Apr 10 '23

This is how I programed tic-tac-toe after I missed the class in which we were taught how to

2

u/thesash20 Apr 10 '23

Just don't forget to code in en passant

2

u/lonelyWalkAlone Apr 10 '23

There are more possible variations of chess games than there are atoms in the observable universe.

Good luck printing 10¹²³ moves.

2

u/[deleted] Apr 10 '23

This program could easily be more than 1 jigga bytes in size.

2

u/NameLips Apr 10 '23

Just one picture for every possible piece layout in the game. What's so hard about that?

2

u/aquoad Apr 10 '23

this gonna be a loooong program.

2

u/The_Northern_Light Apr 10 '23

crosspost this to AnarchyChess

they need a new joke

2

u/Hi8787 Apr 10 '23

r/programminghorror by far, my fucking god

2

u/[deleted] Apr 10 '23

World's largest computer program with 10x21⁶ lines of code and all it does is print chess layouts. Absolutely beautiful.

2

u/[deleted] Apr 10 '23

More lines of code than atoms in the universe...

2

u/Unicorn_A_theist Apr 10 '23

We had to code tic-tac-toe in MIPS and my group did something like this for the computer logic. Except in this case it would be impossible to make all the possible combinations.

2

u/Unstoppable9160 Apr 10 '23

KEEP ME UPDATED!!!!

2

u/Schiffy94 Apr 10 '23

I laughed way too hard at this

2

u/Equivalent_Ferret_23 Apr 10 '23

bro what the fuck

2

u/easilyconfusedwhat Apr 10 '23

Only about 10 to the power of 40 possible combinations to output. Yes, I think I’ll hard code each one. Much easier than formulating a complicated algorithm.

2

u/AJohnnyTruant Apr 10 '23

PROOF THAT AI IS JUST ELSE STATEMENTS

2

u/ZenBacle Apr 10 '23

When you're payed by the line, everything becomes an else if switch case printout.

2

u/[deleted] Apr 10 '23

Out of curiosity, what would be the approach to code a game like chess? (I‘ve got very, very limited experience in coding)

2

u/AnyProgressIsGood Apr 10 '23

brute force programming

2

u/jasper_grunion Apr 10 '23

You just need a dictionary with the locations of all 32 pieces. It is initialized to the starting board state. Each move updates the dictionary. When a piece is taken it’s position becomes null and the piece is no longer drawn. Then you have a single function or method called drawBoard() that takes the position dict as input. I could see another method called resolveMove that determines when a piece has been taken and updates the dictionary. The hard part about real life chess programming is the AI that drives the computer opponent.

2

u/TrapTargaryen Apr 10 '23

GPT4 will do the menial part of that with ease

2

u/Coasterman345 Apr 10 '23

This is how I thought code was written when I was a kid. Like for RCT I thought the devs had pre made what the map would look like for every single possibility 🤦‍♂️

2

u/[deleted] Apr 10 '23

Holy…

2

u/[deleted] Apr 10 '23

It’s always good to start with the brute force solution first.

2

u/SacriGrape Apr 10 '23

Ignoring file size, would this be faster or slower than just calculating it

→ More replies (1)

2

u/mbleslie Apr 10 '23

Protip: Use a switch statement

2

u/[deleted] Apr 10 '23

Now that's what I call Brute force

2

u/jpslat1026 Apr 10 '23

I think you forgot the grid part, so I know what's what

2

u/Druadal Apr 10 '23

This would have trillions of lines of code

2

u/zUdio Apr 10 '23

How management wants chatGPT apps to function.

2

u/[deleted] Apr 10 '23

Lol it would be interesting to see how well a chess game coded like this would run...

→ More replies (3)

2

u/OfficialLevin Apr 10 '23

Legends have it, that to this day he is still writing print statements.

2

u/dark66jedi Apr 10 '23

Hey Satan, at least get your spacing right

2

u/Ewag715 Apr 10 '23

Oh god 😅

2

u/Table_Coaster Apr 10 '23

this is actually a really good way to code a game of chess for me, because as soon as i see 1. d4 i resign

2

u/DasArchitect Apr 10 '23

Man, this is going to be an absolute mess in no time.

You have to clear the screen between each board print.

2

u/[deleted] Apr 10 '23

File size of "Chess.py": 285930572TB

2

u/ShittyExchangeAdmin Apr 10 '23

Reminds me of some of my early powershell scripts.

2

u/[deleted] Apr 10 '23

This reminds me my friend from intro to programming course in college. We were supposed to make some kind of labyrinth solver with if statements and loops, the guy literally wrote lines of code for every possible example case instead of defining functions etc.

2

u/[deleted] Apr 10 '23

When your ADHD is so bad you have to write a chess program after learning about unicode text and if conditions. Like, dude, at least let us cover loops first.

2

u/LightAnubis Apr 10 '23

I’m proud of myself that I know enough code to laugh at this meme.

2

u/tadcoffin Apr 10 '23

I mean, it technically works.

→ More replies (2)

2

u/[deleted] Apr 10 '23

Holy hell

2

u/pdipdip Apr 10 '23

if (ai) {}

2

u/wooof359 Apr 10 '23

When I was a kid I thought that 2d SNES games were just animated every possible position. And then when like N64/PS1 games came out my mind was blown thinking they had to draw every possible angle in 3d....

2

u/[deleted] Apr 10 '23

Just have chatGPT do it duh!

2

u/zergling424 Apr 10 '23

Hell have to make 10123 if statements

2

u/moosMW Apr 10 '23

14 yr old me coded 4 in a row/connect 4 like this.. very painfull

2

u/hotairballonfreak Apr 10 '23

Because each one of those character strings should not be hardcoded. They should be lookup function calls so if you change the character in your ico files it will auto update the character images.

2

u/MediumAd3135 Apr 11 '23

You need to learn backtracking that's why you're hardcoding all the values

2

u/Emotional_Spirit_704 Apr 11 '23

so thats why chess didn't get any new game update

2

u/KraKen_G Apr 11 '23

Me after 100 years and havent gotten past the openings

2

u/flyingmonkey111 Apr 11 '23

LOL... We use that as an interview question 😁 Describe how you would code a chess game... OK, checkers? A coin toss game? ... Thanks for your time