r/ProgrammerHumor • • 14d ago

Meme manWhyTheyGottaMakeGameDevThisHard

Post image
608 Upvotes

70 comments sorted by

181

u/assidiou 13d ago

Should have casted it to a string. If str(str(level_curr)=="15")=="True"

32

u/NightIgnite 13d ago edited 13d ago

Still takes O(n). We can get O(1) with a 32 dimension array

public static int[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,] levelups = new int[2,2,2,...,2,2,2] {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{1,2},{3,4}}, ............., {4294967295, 0}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};

BitArray b = new BitArray(new int[] { level_curr });
return levelups[b[31], b[30], b[29],...,b[2],b[1],b[0]];

16

u/Juandice__ 13d ago

of course, how didn't i think of that

2

u/raunchyfartbomb 12d ago

You laugh, but this is literally how one of our access DBs does its lookups (relationships were never set up, and there are byte columns that lookup integer primary keys. Which, technically ya, I guess that’s valid.

158

u/Noname_FTW 13d ago

Funny. Can't level up past level 4.

28

u/Juandice__ 13d ago

yes, who the hell even levels up from level 3??? nobody does that, old man, get along with times

97

u/MorganTaoVT 13d ago

You don't even reach 4

16

u/XLNBot 13d ago

Maybe there's a default action that happens if no conditional is triggered

15

u/BlackSwanTranarchy 12d ago

else: return level_cur + 1

2

u/XLNBot 12d ago

I wonder if a smart compiler would optimize away the conditionals

3

u/Ecstatic_Student8854 8d ago edited 8d ago

Given that this is python I don’t know, but in a language like C it should be able to. Yet when I tried in godbolt it couldn’t, even at -O3 with gcc. https://godbolt.org/z/n4jsxeazh

Also tried with clang, which could optimise it to a simple +1 at -O2 and even -O1, but not at O3 somehow? Strange. https://godbolt.org/z/K4szrojo8

1

u/-paw- 7d ago

it does, beginning at 5 appearantly.

https://godbolt.org/z/fh5xed53Y

1

u/CasualContributorNZ 13d ago

It'll be at the bottom

258

u/a_normal_user1 13d ago

Yanderedev be like:

81

u/The_Hunster 13d ago

Ya lol. You gotta hand it to him though. He got a lot done considering how shit the code is. Must be hard to work on code that bad.

43

u/a_normal_user1 13d ago

Probably one of the organized messes kind of situations. Like I get navigating through your own mess semi well because you're the only person working on it. But that's completely unacceptable when other people share the code with you. The compiler from my understanding also doesn't have that bad of a time handling code like this. Most of the performance drops came from unoptimized models iirc.

Though I do wonder now what it was like for that one dev that did help clean up his code before Yanderedev threw them out.

10

u/feldim2425 13d ago edited 13d ago

drops came from unoptimized models iirc.

I think interactions/collisions and heart rate monitor also had a few things that cause more overhead than necessary.

But yeah the actual scripts that contained the code where not the issue, I think someone even tried replacing all the if-else with switch-case and it made basically no difference at all.

The compiler from my understanding also doesn't have that bad of a time handling code like this.

IIRC any LLVM based compiler (as an example) doesn't even see the difference in release mode. If-else and switch-case are broken down into the same compilation path.
Debug mode does make a difference since it has to make step-debugging possible which is a entirely different case.

EDIT: Although I don't know how Cpython and other languages as well as other compilers/runtimes handle it. Generally it's well handled in compiled languages at least.

12

u/NamtisChlo 13d ago

A lot done is an interesting statement when it’s been in development for 12 and a half years, lol

8

u/The_Hunster 13d ago

Fair lol. But for like the first 3 years it was a good speed for a solo dev.

5

u/redlaWw 13d ago

I have one fetish game that was built in RPG Maker, and it is, hands down, the most horrible codebase I've ever seen (even putting aside the fact that it's in Japanese which I'm not fluent in). Somehow, though, the game got finished and is one of the best in the genre. Even more surprising is that he managed to not get fed-up wrangling that terror of a codebase and is apparently working on another one.

4

u/ChillyFireball 11d ago

Undertale infamously had some pretty wonky code despite its popularity and success; IIRC, it needed to be rebuilt completely from scratch for the console ports. At the end of the day, though, the user doesn't care as long as the product is good.

81

u/FallenVampireLord 13d ago

Is this pirate software's game?

8

u/Blue_Moon_Lake 13d ago

Looks about right for him.

19

u/Dokattak0 13d ago

He worked at Blizzard for 7 years. He knows how to code!

2

u/Maniklas 8d ago

My cousin worked at a prestigious university for 2 years. He's a janitor at a staffing agency.

5

u/ja_n2000 13d ago

Thought of him first as well

52

u/Legal-Software 13d ago

This looks like the work of someone that spent 7 years at Blizzard.

9

u/KinkyTugboat 13d ago

My dad owns a dealership. I know you didn't ask, I just thought I'd tell you.

1

u/Traditional-Ring-759 13d ago

I have been at a dealership.

22

u/WernerderChamp 13d ago

else: universe.explode()

9

u/Blue_Moon_Lake 13d ago

There's no else, last statement is return 1; so you get to level up all over again up to 3.

1

u/Wonderful-Habit-139 13d ago

Prestige levels…

22

u/emptyevenwithin 13d ago

Ha, I saw a guy do something similar for the minutes and seconds on a clock app he was writing.

5

u/Z3r0funGuy 13d ago

I was really hoping this couldn’t be real..

3

u/stevefuzz 13d ago

This is the reason why people say AI writes better code than humans.

5

u/Draconis_Firesworn 13d ago

i did that once, to convert 24h time to 12h time. On a written exam under time pressure and also I was like 14 at the time

2

u/IntentionQuirky9957 13d ago

12h time is heinous because you can't just do mod 12 for output.

5

u/NamelessJu 13d ago edited 13d ago

It's not really much more complicated than that though, the main conversion can easily be done with mod 12. You just need to replace a resulting 0 with 12 and determine am or pm beforehand by checking if the original 24h value is < or >= 12

0

u/AndrewBorg1126 12d ago

((Hour - 1) % 12) + 1

The difference is fairly trivial

1

u/NamelessJu 11d ago

this is incorrect in the majority of the bigger programming languages, as modulo doesn't have a single defined behaviour for negative operands.
for truncation-based modulo implementations this will return 0 am instead of 12 am, which is not a valid notation in 12h format

15

u/Jet-Pack2 12d ago

Also doesn't work for values between 3 and 9

9

u/CryonautX 12d ago

Doesn't matter, noone levels to 4 in this game.

2

u/Jet-Pack2 12d ago

Everyone stuck at 0

7

u/Fight_The_Sun 13d ago

Pffft... use a switch case next time, n00b

5

u/Pretty-Surround4047 13d ago

Yandere dev downvoted this one

5

u/spastical-mackerel 11d ago

This is what you get for measuring dev productivity by LOC

3

u/Pretty-Surround4047 13d ago

When is level 19 update coming out

3

u/recluseMeteor 13d ago

Is this Toby Fox?

3

u/Thadrea 12d ago

This is why many games have a level cap. They ran out of bytes for more if blocks.

2

u/bem981 13d ago

O(1) function, very optimized!

2

u/mplaczek99 13d ago

This is yandaredev quality

2

u/rpeazy_mcneazy 10d ago

This is the next level of isOdd

2

u/Outrageous_Band9708 8d ago

did pirate software write this code

1

u/pjkm123987 13d ago

I'd use a dictionary for known value mapping.

1

u/Herr_Gamer 12d ago

Pure function without side effects. Testable, composable. I like it!

1

u/Charkid17 12d ago

Sometimes I think I write bad code then I remember stuff like this exists.

1

u/woodyus 1d ago

if (itworks) itworks;

1

u/creeper6530 13d ago

Why is it always game devs doing this shit

3

u/NamelessJu 13d ago

A bunch of gamers get an idea for their own game and wanna try making it, but fail to really understand coding and just wanna get something working That leads to shitty solutions

1

u/Majik_Sheff 12d ago

Treehouse architects.

-1

u/Misel228 13d ago

I hate that Python doesn't have a switch statement. This is the best example for it.

17

u/bobbymoonshine 13d ago

It does, it’s called match-case.

9

u/Misel228 13d ago

hehe, came to shitpost, left with some new knowledge. Thanks.

4

u/Frost-Freak 13d ago

It has already

4

u/Arctos_FI 13d ago

It's named match in python. Also you can get away using dict containing function references as values if you're using such a old version it doesn't have match

7

u/Chronomechanist 13d ago

How is this in any way an example of the use for a switch case? This is an example of people with no basis sitting behind a computer being allowed to code.

0

u/Misel228 13d ago

Personally, I wouldn't take replies too seriously in this sub.

2

u/GoddammitDontShootMe 13d ago

Didn't even notice it was Python at first. Then they should definitely be able to just return level_curr + 1.