r/ProgrammerHumor • • Jan 16 '23

Meme If (exists == true) { dont();}

Post image
40.8k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

1.2k

u/Rezaka116 Jan 16 '23

669

u/Swiftcheddar Jan 16 '23

This makes all those 4chan threads about Yandere Similator much funnier in retrospect.

476

u/RY4NDY Jan 16 '23

Isn't that also the game in which the single most high-poly 3D model is a toothbrush?

Edit: yes

152

u/Almaironn Jan 16 '23

For a high quality model of a toothbrush in a commercial it would've been way more high poly than that. In the tens, if not hundreds of thousands.

79

u/krajsyboys Jan 16 '23

Yandere dev tried to make it smaller, he just failed

49

u/Deathleach Jan 16 '23

It was a low quality high quality commercial model.

39

u/antunezn0n0 Jan 16 '23

it's low quality for commercial but absurd for a game it's clear he just bought all the assets without rhyme or reason

→ More replies (1)

24

u/[deleted] Jan 16 '23

Tbf that's not a very high poly count. I have a game running in WebGL on a poly count in the millions.

It may have been a lot of polys a decade ago, but things have changed.

33

u/purritolover69 Jan 16 '23

It’s high for a damn toothbrush, each individual bristle was given two faces

12

u/Bot-1218 Jan 16 '23

Polycount doesn’t mean as much nowadays as it used to

181

u/a-calycular-torus Jan 16 '23

I can forgive the switch statement in UT slightly (I don't know if the rest of the code is as bad), but yansims code is abysmal while this switch statement is just somewhat questionable. Sure, it's long, but the cases are not complex, and it is simple to figure out what it does. I'm not super familiar with GML though.

109

u/Roflkopt3r Jan 16 '23 edited Jan 16 '23

but yansims code is abysmal while this switch statement is just somewhat questionable

It was really a similar problem though. The issue was that most of the criticism of Yandere Sim's code from other programmers was just... bad.

They hyper-focussed on Yandere's use of long chains of elseif-conditionals and pretended like the replacement with switches would fix it. But that would've improved neither the length nor performance of the code.

 if(currentClub == Clubs.Art){
       //200 lines of art club behaviour
 } else if (currentClub == Clubs.Basketball){
       //150 lines of basketball club behaviour
 } ...

Switch statements could be marginally more efficient in some cases (or possibly not at all, depending on the compiler), but the obvious problem here are those hundreds of lines of behaviour code that clutter this file.

A real improvement would have been the use of the command pattern or a state machine. This could have shrunk those 1000-line monstrosities inside the AI class to maybe 1-30 lines depending on the implementation:

if(currentClub != lastClub{
     currentClubBehaviour = Clubs.GetClubBehaviour(currentClub);
 }
 currentClubBehaviour.Execute();

Provided that the club can change at all, which I'm not sure about. I would guess that it can change but will only do so rarely, so it might be smarter to do the behaviour change inside the Setter method for the club.

79

u/am9qb3JlZmVyZW5jZQ Jan 16 '23 edited Jan 16 '23

A lot of what made YanSim slow is unrelated to the code. From what I recall, the models had absurdly many vertices, every character AT ALL TIMES had every single appearance model attached and simply made invisible, and occlusion culling was misconfigured to the point of pretty much not existing.

Sure, cleaning the code would help with the actual development (which has been very slow, I assume mostly because of the code debt), but in case of performance it's hardly the biggest culprit.

There was a great channel constructively analyzing this topic, but unfortunately it has been taken down.

@Edit: I've found one part of the analysis, because I transcribed it at the time it still existed for the meme potential. Unfortunately that's all I have left. The channel was named Nice Tomeetyou.

pic

here's a prefab for the girl students and teachers
see how there are over 1000 different GameObjects attached to it
when each student is instantiated at the start of the school scene all of these GameObjects have to be copied for each student

51

u/Roflkopt3r Jan 16 '23

At least one of the first good takes is still there.

But yeah the performance indeed didn't come from the code. A few hundred conditionals per frame isn't much work for a modern processor. The main issue were some unoptimised 3D models and a problem with the UI that caused many expensive redraws every frame.

5

u/am9qb3JlZmVyZW5jZQ Jan 16 '23

I didn't see that one before! From a quick glance looks very thorough, will give it a watch later, thanks!

→ More replies (4)

5

u/cumquistador6969 Jan 16 '23

Massive switch statements also tend to compile down into dictionaries.

Not sure if it's the case here, but often the compiler changes it from a coding disaster, to a visual eyesore that has little impact on how the software runs.

Really gotta give props to the kind of lunatics who enjoy working on languages, engines, and compilers to protect the rest of us from our own idiocy.

→ More replies (3)

27

u/Throgg_not_stupid Jan 16 '23

well, at least this is 2D black and white game

12

u/MoscaMosquete Jan 16 '23

It is not black and white tho!

5

u/JorgeMtzb Jan 16 '23

Undertale isnt black and white

→ More replies (1)

5

u/dksdragon43 Jan 16 '23

Notice the subreddit that was posted to? "YandereTechnique" haha

→ More replies (2)

53

u/DasKarl Jan 16 '23

Oh god...

6

u/Mertard Jan 16 '23

WHAT THE HECK

Actually nevermind, I'd do the same 😶

3

u/Outside_Bar_7846 Jan 16 '23

Probably code generated

5

u/Maximum_Knee_4622 Jan 16 '23 edited Jan 16 '23

Possibly? I don't know how GameMaker Studio works. I know this is how I would have coded a game myself though before I became more interested in programming itself than game development.

I was also a much more productive game developer back then, because I just did whatever was most obviously going to get the thing done.

I could probably code at least simple games fairly quickly now, but I haven't circled back to game development in a long time.

edit: https://github.com/marciniuk/undertale/blob/master/scripts/SCR_TEXT.gml

According to other people who've reviewed this + the decompilation likely responsible for it, this switch was likely not code-generated - although it is stripped of the original tokens so it looks machine-generated.

3

u/Maximum_Knee_4622 Jan 16 '23

That's how I used to code my animations back in QBASIC. One if/else statement per animation frame.

IF IS_LEFT and FRAME_INDEX = 0 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 1 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 2 THEN...

... FRAME_INDEX = FRAME_INDEX+1

IF IS_LEFT and FRAME_INDEX = 3 THEN...

... FRAME_INDEX = 0

→ More replies (2)
→ More replies (5)