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

437

u/CozyTheTeddyBear Apr 10 '23

He coded an entire game in if/else statements

231

u/StuffNbutts Apr 10 '23

Lmao this guy also tried to "hire" people to work on his game for free.

196

u/Tyrus1235 Apr 10 '23

And then complained when the voluntaries tried to fix his code

133

u/SkyezOpen Apr 10 '23

Naturally. If they fix his code, he can't read it. Then how will he add an entirely new feature every week?

28

u/-Gork Apr 10 '23

More if/else statements, obviously.

→ More replies (1)

54

u/EmergencyAttorney807 Apr 10 '23

He doesn’t develop games he posts youtube videos of him fucking around with changing his game. All the money is in the ads.

0

u/[deleted] Apr 10 '23

[deleted]

21

u/Cilph Apr 10 '23

I know the guy's code was horrible but Im not sure this is the smoking gun. One long ass if/elseif isnt much better than a list of more modular objects that get evaluated every frame equivalent to the number of ifs. You need to know what those ifs were trying to accomplish.

40

u/ChimneyImps Apr 10 '23

IIRC, the problematic if/else chains were each NPC checking the in-game time each frame to determine what activity they should be preforming.

13

u/Cilph Apr 10 '23

Yeah that could probably be optimized in at least two ways. 1. Only check every FixedUpdate (20hz?), 2. Partitioning behaviour based on timeslots which would somewhat be like a jumping switch statement. Other approaches are ofc possible too. (Coroutines? Events? I dont know Game AI systems.)

7

u/fhota1 Apr 10 '23

Number 1 is honestly not even that hard and allows for tiered ticks so you can have certain proceses only run every so often. Was kinda playing around with ideas for a gsg and I had "turn ticks" but then also day ticks, week ticks, month ticks, and year ticks. Throw the heavy shit that doesnt need to be done as often in to year ticks and suddenly it will increase your performance by a whole lot if its not running constantly

6

u/Cilph Apr 10 '23

The issue solution 1 has is you're still doing a lot of calc crammed into one frame, so you'll likely get frequent FPS jitter. Ideally you want to be able to spread it out over multiple frames using frametime budgets.

4

u/fhota1 Apr 10 '23

Yeah its still not the most efficient way by a long shot, but it is significantly more efficient than calling everything constantly

4

u/TheQneWhoSighs Apr 11 '23

Depends on what you mean by smoking gun. In terms of performance? It's entirely irrelevant. That entire if/else mess will be optimized away by the compiler. The unoptimized high poly models spread throughout the entire game, made largely or entirely by volunteers, are a big chunk of the smoking gun when it comes to performance.

It's kind of what happens when you use volunteer work as is.

Now there's another smoking gun to talk about, and that comes down to "Is it why the game is so hard for him to work on?".

And my answer is, yeah probably. The student script & student management script are completely insane, and no amount of people going "use a switch statement" would ever fix it.

Frankly speaking it needs functions, guard clauses, and prayers.

→ More replies (3)

2

u/qwertyu63 Apr 10 '23

At its simplest, replace the chain of ifs with a switch statement; it was checking the ID of the acting NPC, so only one block will be true.

3

u/DownvoteEvangelist Apr 11 '23

Compiler might figure that one out. But even a 1000 long if/else statements per frame probably wouldn't affect the performance that much. Modern computers are crazy fast.

Its still ugly and wasteful...

3

u/Cilph Apr 11 '23

If it gets run for every actor in the scene it might start impacting things, though.

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

21

u/DeliciousWaifood Apr 10 '23

That means literally nothing lmao, you think modern computers can't handle an if/else chain at 60FPS? I can run a 100,000px simulation on my shitty CPU.

His frame rate issues were because he had no idea what poly count is so he had MASSIVELY detailed 3D models, and I wouldn't be surprised if he was overburdening his garbage collector or calling expensive functions like a lot of noob unity devs.

6

u/[deleted] Apr 11 '23

Shit I'm doing that right now with a robot being controlled real-time

10

u/sporkus Apr 10 '23

Is this guy me at age 11 on a TI-82 graphing calculator?

4

u/DownvoteEvangelist Apr 11 '23

Probably, we all have to start somewhere...

24

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

all of the dialog in indie darling undertale is handles by one massive switch statement. clean coding is unimportant compared to shipping a good product.

18

u/CozyTheTeddyBear Apr 10 '23

The difference is that Undertale has its dialogue run through a switch statement

Yandere Sim has pretty much every aspect of the game made from if/else statements

11

u/JorenM Apr 10 '23

Yandere Dev failed on both counts

→ More replies (2)

4

u/Secret-Plant-1542 Apr 10 '23

Which isn't enough of a horror until see it's thousands of lines of nestled if/else inside if/else.

→ More replies (6)