YandereDev’s story: Yandere Simulator Code

Over the years, many people have made incorrect statements about YandereDev’s code programming ability in the Yandere Simulator. In this article, YandereDev will discuss and debunk false allegations.

Outdated Code Examples

At the beginning of Yandere Simulator’s development, YandereDev’s goal was to quickly create a rough proof-of-concept that could be used for pitching the game on Kickstarter. During that period, YandereDev was not concerned with writing efficient or optimized code, because YandereDev was not planning for any of that code to be in the final version of the game. That code was written so YandereDev could showcase gameplay in YouTube videos and the planned Kickstarter pitch, and that was it.

However, as YandereDev added more and more features to the proof-of-concept, it gradually became apparent that YandereDev was creating a feature-complete slice of the complete game. Instead of following the original plan, YandereDev decided to use the proof-of-concept as the base for the actual game. With this in mind, YandereDev began to write cleaner code and also optimized a lot of the least-efficient code that had been written in the game’s earliest stages.

However, people used third-party tools to crack open the game, looked at the earliest code, shared screenshots of it, and accused YandereDev of being a bad programmer.

For example, this image depicts an inefficient use of else-if statements in Yandere Sim’s code: https://i.imgur.com/xhLuMnS.png

However, those else-if statements were replaced with switch statements several years ago: https://i.imgur.com/TLhi3Me.png

It is dishonest to attempt to portray YandereDev as a bad programmer using screenshots of code that doesn’t even exist in the game anymore, or code that was already re-written and optimized a long time ago.

Else-If Statements

Some people insist that “Yandere Simulator has a low framerate because of else-if statements.” However, else-if statements don’t have a significant impact on a game’s framerate. Computers are extremely fast at iterating through lists. A computer can indeed iterate through a list of switch statements faster than a list of else-if statements, but the difference would be less than a millisecond. It’s not enough to affect a game’s framerate.
(Anyone can test this by making two scripts that perform an identical operation, using else-if statements in one script and switch statements in the other script. Tell the computer to log how much time it takes to execute each script, and you’ll see that the difference between else-if and switch is so minor that it’s completely irrelevant.)

Even with that said, there is yet another reason why these accusations are invalid. Although there are still a few scripts in the game where YandereDev employs a long chain of else-if statements, most of those scripts only run for one frame. A script that only runs for one frame and then never runs again cannot possibly affect a game’s framerate.

And, even with that said, there is still yet another reason why it is pointless to criticize the use of else-if statements. Even if we were to assume that else-if statements ARE a big problem, it doesn’t take much time to simply edit the script and convert them into switch statements.

Converting this: https://i.imgur.com/YDxgzXB.png

Into this: https://i.imgur.com/9aisiH0.png

Only takes a few seconds. Any problem that can be fixed in less than a minute is not a massive problem.

Code Affecting Framerate

Yandere Simulator is made with the Unity game engine. Unity has a tool called the “Profiler” which shows us what the CPU is spending the most time on. Using the Profiler, we can see what the CPU spends its time doing when running Yandere Simulator.
The Profiler shows us that the CPU spends 48% of its time on rendering, and only 12% of its time executing the “Update()” function of scripts: https://i.imgur.com/eJEs5m5.png

This discredits the idea that “bad code” is the culprit of any framerate issues found in Yandere Simulator. Improving Yandere Simulator’s framerate will involve making optimizations to rendering, not code.

The most “heavy” script in the game, StudentScript, only takes up 2% of the CPU’s time, and that’s only because there are 88 of them running simultaneously: https://i.imgur.com/gGjtav0.png

That’s right – the one script that uses the most else-if statements needs to run 88 times to make even 2% of a difference.

It may be worth mentioning that “Yandere Simulator has bad framerate!” became a meme many years ago when Yandere Simulator did suffer from performance issues. However, the game has been through many optimizations and framerate improvements since then, making the meme less and less accurate with time. In 2016, it would have been true to say that even a powerful computer could not run Yandere Simulator at an acceptable framerate, but that same computer should have no problem running a 2022 build of Yandere Sim.

Download a build from 2016 and a build from 2022 and test them yourself if you don’t believe YandereDev.

The bottom line is that most the people who have attempted to critique YandereDev’s code have made a very large number of completely invalid statements to their audiences, leading countless people to develop an inaccurate perception of YandereDev’s coding ability.

Leave a Reply