Code

Unfortunately, there is a tremendous amount of misinformation about Yandere Simulator's code on the Internet. On this page, I will discuss and debunk that information.

Outdated Code Examples

At the beginning of Yandere Simulator's development, my goal was to quickly create a rough proof-of-concept that could be used for pitching the game on Kickstarter. I only wanted to create a simple prototype that would allow me to demonstrate the planned features and mechanics that the final game was meant to have. During that period of time, I was not concerned with writing efficient or optimized code, because I was not planning for any of that code to be in the final version of the game. That code was only written so I could showcase gameplay in YouTube videos and the Kickstarter pitch.

However, as I added more and more features to the proof-of-concept, it gradually became apparent that I was basically creating a feature-complete slice of the complete game. Instead of following the original plan, I decided to use the proof-of-concept as the base for the actual game. With this in mind, I 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 me 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 and misleading to portray me 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

There are people who insist that "Yandere Simulator has a low framerate because of else-if statements." However, else-if statements don't actually have a significant impact on a game's framerate. Computers are extremely fast at iterating through lists. It is true that a computer can 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 I employ 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 else-if statements actually WERE a big problem, it doesn't take much time to edit a script to convert else-if statements 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 significant 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.pngThis 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.pngThat'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 a bad framerate!" became a meme many years ago, when Yandere Simulator actually 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 the passage of time. In 2016, it would have been true to say that even a powerful computer could not run Yandere Simulator at an acceptable framerate. However, that same computer should have no problem running a 2023 build of Yandere Sim. (You can download a build from 2016 and a build from 2023 and test them yourself if you don't believe me.)

The bottom line is that most the people who have attempted to critique my code have made a very large number of completely incorrect and invalid statements to their audiences, leading countless people to develop an inaccurate perception of Yandere Simulator's code and my own programming ability.