What happens if the in-game value of pi is not '3.14159...'?



It is well known that pi is an irrational number and its value is '3.14159 ...'. Such pi is sometimes used in games as part of graphical programming and visual rendering, but the value of pi used in the legendary FPS game '

Doom ' is said to be incorrect. Software engineer Luke Gotzling explained what would happen if such an 'incorrect pi' was used in a game.

Non-Euclidean Doom: what happens to a game when pi is not 3.14159… - media.ccc.de
https://media.ccc.de/v/mch2022-236-non-euclidean-doom-what-happens-to-a-game-when-pi-is-not-3-14159-

Pi is the ratio of the circumference to the diameter of a circle. Its value to 10 decimal places is '3.1415926535', and its approximate value is '3.141592654'. However, the value of Pi introduced in Doom was '3.14159265 7 '. This is because developer John Carmack 'misremembered the value of Pi'. In fact, Carmack himself acknowledged this fact.




This value of Pi was used in Doom's lookup table . In 1993, hardware did not have the specialized 3D image processing capabilities such as 3D acceleration, so in order to speed up all queries, any data that could be calculated in advance had to be calculated in advance. The data structure for this purpose was the lookup table.

Carmack says that he entered an incorrect value there, but that it did not affect actual gameplay.

So Gotzling decided to tinker with the values and see what problems putting in the wrong values could cause.

First, let's double the value of pi. This will still compile, but you will not be able to actually play the game. The same thing happens if you set the value of pi to '4' - it will compile but you will not be able to play the game.



However, if you set the value of pi to '3', you can compile and play the game. This causes the game's values to be out of sync in places, resulting in bugs such as the main character dying in the demo scene at the beginning of the game, even though he normally cannot die.



When you actually play the game, you may notice distortion on the screen and walls moving in unexpected ways.



If you set the value of pi to 'e (Napier's constant)', the screen will visibly shake.



If you set it to π/2, the texture will become more distorted.



If you set π = 0.00001, a strange scene will appear where someone shoots a gun at the title screen.



As far as Gotzling tried, he was able to both compile and play with several numbers, as shown below.



In addition, there are many projects that have copied the source code without knowing that such 'incorrect pi' exists, and the number is as many as 2124. 'Did these people copy and use it thinking that it was the correct value of pi? I'm sure the answer is yes,' said Gotzling.



in Game, Posted by log1p_kr