How FNaF's RNG Broke... 3 times

Full Transcript — Download SRT & Markdown

00:00
Speaker A
Even though Golden Freddy is one of the simplest enemies in the FNAF games,
00:05
Speaker A
everyone, and I mean everyone for the past nine years, has been completely wrong about how often he appears.
00:11
Speaker A
Judging from the code, it looks pretty cut and dry, it's literally just every second, there's a one in 100,000 chance for the Golden Freddy poster to appear, so how is that wrong?
00:23
Speaker A
Well, let me explain with an entirely separate but surprisingly simple glitch.
00:29
Speaker A
In Freddy Fazbear's Pizzeria Simulator, having negative stats, oh, hold on, you probably don't know how to get negative stats.
00:36
Speaker A
Okay, so placing animatronics or attractions adds stats, and removing it subtracts stats, easy, great.
00:43
Speaker A
For whatever reason, Scott decided to make it take five frames for stats to actually be added after you place an attraction, but it immediately saves that you placed it down.
00:54
Speaker A
Because of this, if you place an attraction and immediately leave blueprint mode, it remains down without its stats being added.
01:00
Speaker A
Then you can remove it, subtracting whatever stats you would have gained, and you have less than you started with.
01:07
Speaker A
Amazing, that's...
01:10
Speaker A
Well, no, that doesn't seem helpful.
01:14
Speaker A
Now what's going to happen?
01:18
Speaker A
You're going to lose money at the end of the day?
01:20
Speaker A
Far from it.
01:24
Speaker A
You can get tens of thousands.
01:28
Speaker A
That is very odd.
01:30
Speaker A
We should have a look at how it calculates that revenue.
01:33
Speaker A
All right, so that first part is going to be negative because the revenue stat is negative.
01:39
Speaker A
Though it won't subtract much.
01:41
Speaker A
But what numbers is that second part generating?
01:44
Speaker A
It's supposed to just be random numbers from zero to some maximum, in this case, the revenue stat.
01:50
Speaker A
But what happens when it's negative?
01:52
Speaker A
It's actually generating numbers up to 60,000.
01:55
Speaker A
There's definitely something amiss.
01:57
Speaker A
Clickteam Fusion, the game engine, handles that maximum number as an unsigned short.
02:03
Speaker A
Unsigned meaning we don't store if it's positive or negative, and short referring to how many bits of data we're going to use to store the number, 16.
02:10
Speaker A
And because each bit can be zero or one, it can hold numbers from zero to 65,000.
02:15
Speaker A
When our revenue stat is negative, that's below the range the variable can hold.
02:21
Speaker A
Depending on the programming language, that's either going to result in an error or wrapping the number around to the maximum.
02:29
Speaker A
That last one is the easiest and most common implementation.
02:32
Speaker A
And the implementation in our case.
02:34
Speaker A
So, random minus one wraps around to the maximum.
02:38
Speaker A
It's making random numbers from zero to 65,000.
02:41
Speaker A
But how does that relate to Golden Freddy?
02:45
Speaker A
We're not trying to get negative numbers, he's supposed to be one in 100,000, not one in negative 10.
02:50
Speaker A
But we are still trying to generate numbers outside the unsigned short's range.
02:57
Speaker A
100,000 is a decent bit above 65,000.
03:01
Speaker A
So it ends up wrapping around to 34,464.
03:05
Speaker A
But he's still almost three times as common as everyone thought.
03:10
Speaker A
But Golden Freddy can't be the only thing affected by this.
03:13
Speaker A
Let's take a quick look at the odds of other rare events in the point and click FNAF games.
03:19
Speaker A
In the original, only Golden Freddy is affected, nothing else.
03:24
Speaker A
But in FNAF 2, there's RWQFSFASXC or Shadow Bonnie at one in a million.
03:30
Speaker A
Nothing else is nearly that rare though.
03:32
Speaker A
FNAF 3 has a bunch of rare stuff, but nothing above 65,000 and nothing below zero, so it should be okay.
03:39
Speaker A
FNAF 4 barely had any rare events anyway, so I didn't expect to see anything.
03:45
Speaker A
FNAF World has a technicality if you cheat in extremely high character levels.
03:51
Speaker A
But nothing theoretically possible without editing your save file.
03:55
Speaker A
There is a bunch of rare stuff that can only happen once a night, but I think you can identify the odd one out here.
04:02
Speaker A
These numbers in Sister Location's breaker room are supposed to be random numbers for a billion, but clearly that did not work.
04:10
Speaker A
And the numbers only go up to 51,000.
04:12
Speaker A
We already know Pizzeria Simulator can have something go wrong with the stats.
04:17
Speaker A
Nothing else does though.
04:18
Speaker A
Nothing naturally goes wrong in UCN, but if you were one of the people who knew that you can get negative AI levels if you have a double clicking mouse.
04:26
Speaker A
You might have expected UCN to have something.
04:28
Speaker A
Unfortunately, it makes sure that most animatronics don't function or don't function properly if their AI level is below one for obvious reasons.
04:36
Speaker A
But there's an important exception in our case with Jack-O-Chica, who when having negative one AI essentially auto-kills you.
04:43
Speaker A
After only a second of the temperature being above 90.
04:47
Speaker A
Because it tries to add twice a random number from zero to 65,000, when the kill threshold is only 500.
04:54
Speaker A
So, overall, Golden Freddy and Shadow Bonnie end up being the only ones affected by this.
05:02
Speaker A
But this still makes a huge difference for both of them.
05:05
Speaker A
Shadow Bonnie is almost 60 times as likely as previously thought.
05:10
Speaker A
And he actually ends up falling behind both Golden Freddy and Mystery Box Jack-O-Bonnie in rarity.
05:15
Speaker A
And that's about where this video would have ended.
05:19
Speaker A
If I didn't look even further into the random number generator.
05:25
Speaker A
One in 34,464 is a very precise probability.
05:30
Speaker A
Can the game even accurately simulate that?
05:32
Speaker A
Well, for most programming languages, the actual random numbers generated are 32-bit or more, going into the billions.
05:40
Speaker A
So you can get very close.
05:42
Speaker A
But as we've seen, Clickteam Fusion generates 16-bit integers.
05:46
Speaker A
Only going up to 65,000.
05:48
Speaker A
When you're trying to reduce that range of random numbers to a smaller range, like random numbers from one to 100.
05:56
Speaker A
And those two ranges don't cleanly divide each other, that can result in a slight bias.
06:01
Speaker A
Imagine it like trying to roll a 10-sided die, acting as our random number generator.
06:08
Speaker A
And trying to get random numbers from one to four from that.
06:11
Speaker A
Some of the numbers will have three outputs associated with them, while others will only have two.
06:18
Speaker A
The ones with three will be more likely, and without using rejection sampling, that's unavoidable.
06:22
Speaker A
When our random number generator is rolling a 65,000-sided die, and we're generating a small range of numbers.
06:29
Speaker A
The amount of bias is minuscule.
06:31
Speaker A
It goes from one in three to one in 2.9999.
06:34
Speaker A
But when you start getting to rare events, all of a sudden for random numbers to 10,000.
06:40
Speaker A
Some numbers are one in 9,300, others are one in 11,000.
06:45
Speaker A
Specifically, for our two super rare occurrences, simulating the random number generator reveals their odds increase even further.
06:52
Speaker A
To exactly one in 32,768 and Shadow Bonnie to one in 16,384.
06:59
Speaker A
And that's another place the video could have ended.
07:03
Speaker A
If I didn't find another thing.
07:06
Speaker A
Starting research into the random number generator, it was found that there used to be a game-breaking error in Clickteam Fusion's Android runtime.
07:13
Speaker A
That affects Golden Freddy in the opposite way.
07:16
Speaker A
The game engine was fixed in build 284.3 in early 2015, but that was after the last patch to the old Android port of FNAF 1.
07:24
Speaker A
So it still affected the game on Android until the remaster in mid-2019.
07:29
Speaker A
It's important to note that the Windows runtime was written in C++, which has the unsigned short data type we were talking about.
07:36
Speaker A
While the Android runtime was built in Java.
07:40
Speaker A
Which only natively supports signed shorts.
07:43
Speaker A
The range of numbers is slightly different between the two.
07:45
Speaker A
What happened is that rather than properly emulating unsigned shorts, before they fixed it, they just used signed shorts.
07:53
Speaker A
Which meant the upper limit was even lower, and it wrapped around to negative 32,000 instead of zero.
07:59
Speaker A
This error caused the random number generator to instead generate only negative numbers for some ranges of values, including 100,000.
08:06
Speaker A
That's a big problem, especially if you're say, checking if the random number is equal to one.
08:12
Speaker A
A notably non-negative number.
08:14
Speaker A
What I'm saying is, the rumor is true, we finally have actual reasoning and evidence that Golden Freddy did not exist in the old Android port.
08:23
Speaker A
He wasn't like 10 times rarer or something.
08:25
Speaker A
The random number generator just happened to be entirely broken, but specifically, only for him and nothing else.
08:33
Speaker A
I can only hope that was mostly understandable.
08:37
Speaker A
Thanks to True Player for being the starting point for this investigation.
08:43
Speaker A
And Univers and Folmic for helping to make this video possible.
08:46
Speaker A
And thanks to Exploding Bears, my only Taken++ member.
08:50
Speaker A
Big fan.
08:52
Speaker A
Now watch one of these videos.
08:55
Speaker A
Or Scott at all.

Get More with the Söz AI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries, speaker detection, and unlimited transcriptions.

Or transcribe another YouTube video here →