ABSTRACT
Early video games didn’t have hardware support for random number generation, so developers used software-based RNG. We show that hundreds of games in the Nintendo Famicom / NES library regenerate the same pseudorandom sequence of 32, 767 bits, although the machine code for doing so comes in more than one hundred variants. We identified the disparate implementations using a simple regular expression that matches the following “fingerprint” of operations: LDA, AND, STA, LDA, AND, EOR, CLC, BEQ, SEC, ROR. These instructions implement a classic 15-bit linear feedback shift register associated with x15 + x7 + 1 (i.e., tap the 15th and 7th bits). However, many games devoted more memory to the LFSR’s state. For example, Donkey Kong (1983) used 8 bytes (or 8 · 8 = 64 bits), The Legend of Zelda (1986) used 13 bytes, and Super Mario Bros. 3 (1988) used 9 bytes. In each case, additional entropy is lost by a simple programming error: the bits are shifted in the wrong direction.
- Abbas Alhakim, Evan Sala, and Joe Sawada. 2021. Revisiting the prefer-same and prefer-opposite de Bruijn sequence constructions. Theoretical Computer Science 852 (2021), 73–77.Google ScholarCross Ref
- Abbas M Alhakim. 2010. A simple combinatorial algorithm for de Bruijn sequences. The American Mathematical Monthly 117, 8 (2010), 728–732.Google ScholarCross Ref
- Matt Alt. 2020. The Designer Of The NES Dishes The Dirt On Nintendo’s Early Days. https://www.kotaku.com.au/2020/07/the-designer-of-the-nes-dishes-the-dirt-on-nintendos-early-days/.Google Scholar
- Internet Archive. 2020. [No-Intro] Nintendo - Nintendo Entertainment System. https://archive.org/details/nointro.nes.Google Scholar
- John Aycock. 2016. Retrogame Archeology: Exploring Old Computer Games (1st ed.). Springer, New York, NY, USA.Google ScholarCross Ref
- Pradipto Banerjee and Michael Filaseta. 2010. On a polynomial conjecture of Pál Turán. Acta Arith 143, 3 (2010), 239–255.Google ScholarCross Ref
- John Adrian Bondy, Uppaluri Siva Ramachandra Murty, 1976. Graph theory with applications. Vol. 290. Macmillan London.Google Scholar
- Ben Cameron, Aysu Gündoğan, and Joe Sawada. 2022. Cut-Down de Bruijn Sequences. arXiv preprint arXiv:2205.02815(2022).Google Scholar
- Joseph DiMuro. 2019. Classifying rotationally-closed languages having greedy universal cycles. The electronic journal of combinatorics26 (2019), P1.35. Issue 1.Google Scholar
- Patrick Baxter Dragon, Oscar I Hernandez, Joe Sawada, Aaron Williams, and Dennis Wong. 2018. Constructing de Bruijn sequences with co-lexicographic order: The k-ary Grandmama sequence. European Journal of Combinatorics 72 (2018), 1–11.Google ScholarCross Ref
- Patrick Baxter Dragon, Oscar I Hernandez, and Aaron Williams. 2016. The grandmama de Bruijn sequence for binary strings. In LATIN 2016: Theoretical Informatics. Springer, 347–361.Google Scholar
- Michael Filaseta. 2014. Is Every Polynomial with Integer Coefficients Near an Irreducible Polynomial?Elemente der Mathematik 69, 3 (2014), 130–143.Google Scholar
- Michael Filaseta and Michael Mossinghoff. 2012. The distance to an irreducible polynomial, II. Math. Comp. 81, 279 (2012), 1571–1585.Google ScholarCross Ref
- Harold Fredricksen and James Maiorana. 1978. Necklaces of beads in k colors and k-ary de Bruijn sequences. Discrete Mathematics 23, 3 (1978), 207–210.Google ScholarCross Ref
- Daniel Gabric and Joe Sawada. 2022. Investigating the discrepancy property of de Bruijn sequences. Discrete Mathematics 345, 4 (2022), 112780.Google ScholarDigital Library
- Daniel Gabric, Joe Sawada, Aaron Williams, and Dennis Wong. 2018. A framework for constructing de Bruijn sequences via simple successor rules. Discrete Mathematics 341, 11 (2018), 2977–2987.Google ScholarCross Ref
- Daniel Gabric, Joe Sawada, Aaron Williams, and Dennis Wong. 2019. A successor rule framework for constructing k-ary de Bruijn sequences and universal cycles. IEEE Transactions on Information Theory 66, 1 (2019), 679–687.Google ScholarDigital Library
- Petar Gaydarov and Konstantin Delchev. 2015. Combinatorial Computations on an Extension of a Problem by Pál Turán. Serdica Journal of Computing(2015), 257–268.Google Scholar
- Solomon W. Golomb. 1981. Shift Register Sequences(1 ed.). Aegean Park Press.Google Scholar
- Mark Hendrikx, Sebastiaan Meijer, Joeri Van Der Velden, and Alexandru Iosup. 2013. Procedural content generation for games: A survey. ACM Transactions on Multimedia Computing, Communications, and Applications 9, 1(2013), 1–22.Google ScholarDigital Library
- Cees JA Jansen, Wouter G Franx, and Dick E Boekee. 1991. An efficient algorithm for the generation of DeBruijn cycles. IEEE Transactions on Information Theory 37, 5 (1991), 1475–1478.Google ScholarDigital Library
- Thomas Jentzsch. 2017. Pitfall!x256 (was: Pitfall!x16). https://atariage.com/forums/topic/267046-pitfallx256-was-pitfallx16.Google Scholar
- Donald E Knuth. 2005. The Art of Computer Programming, Volume 4, Fascicle 2: Generating All Tuples and Permutations. Addison-Wesley Professional.Google ScholarDigital Library
- Donald E Knuth and Len Shustek. 2021. Let’s not dumb down the history of computer science. Commun. ACM 64, 2 (2021), 33–35.Google ScholarDigital Library
- Gilbert Lee, Frank Ruskey, and Aaron Williams. 2007. Hamming distance from irreducible polynomials over . Discrete Mathematics & Theoretical Computer Science DMTCS Proceedings vol. AH, 2007 Conference on Analysis of Algorithms (AofA 07) (Jan. 2007). https://doi.org/10.46298/dmtcs.3550Google Scholar
- Monroe H Martin. 1934. A problem in arrangements. Bull. Amer. Math. Soc. 40, 12 (1934), 859–864.Google ScholarCross Ref
- Damien McFerran. 2018. Feature: Shining A Light On Ikegami Tsushinki, The Company That Developed Donkey Kong. https://www.nintendolife.com/news/2018/02/feature_shining_a_light_on_ikegami_tsushinki_the_company_that_developed_donkey_kong.Google Scholar
- Mike Mika. 2013. Why I hacked Donkey Kong for my daughter. Wired, March 11(2013).Google Scholar
- Nick Montfort and Ian Bogost. 2009. Racing the beam: The Atari video computer system. Mit Press.Google Scholar
- Nick Morgan. 2012. Easy 6502 Simulator. https://skilldrick.github.io/easy6502/simulator.html.Google Scholar
- Trang Q. Ngo. 2020. Python implementation of Dr. Mario algorithms. https://github.com/trangqngo/Dr-Mario-virus-generation.Google Scholar
- nightmareci. 2012. Dr. Mario virus placement. https://tetrisconcept.net/threads/dr-mario-virus-placement.2037.Google Scholar
- nightmareci. 2013. Dr. Mario. https://tetris.wiki/Dr._Mario.Google Scholar
- Robert Xiao (nneonneo). 2015. bgrep. https://github.com/nneonneo/bgrep.Google Scholar
- Frank Ruskey, Carla Savage, and Terry Min Yih Wang. 1992. Generating necklaces. Journal of Algorithms 13, 3 (1992), 414–430.Google ScholarDigital Library
- Frank Ruskey, Joe Sawada, and Aaron Williams. 2012. De Bruijn sequences for fixed-weight binary strings. SIAM Journal on Discrete Mathematics 26, 2 (2012), 605–617.Google ScholarCross Ref
- Joe Sawada, Aaron Williams, and Dennis Wong. 2016. Generalizing the classic greedy and necklace constructions of de Bruijn sequences and universal cycles. The electronic journal of combinatorics(2016), P1–24.Google Scholar
- Joe Sawada, Aaron Williams, and Dennis Wong. 2016. A surprisingly simple de Bruijn sequence construction. Discrete Mathematics 339, 1 (2016), 127–131.Google ScholarDigital Library
- Joe Sawada, Aaron Williams, and Dennis Wong. 2017. A simple shift rule for k-ary de Bruijn sequences. Discrete Mathematics 340, 3 (2017), 524–531.Google ScholarDigital Library
- Noor Shaker, Julian Togelius, and Mark J Nelson. 2016. Procedural content generation in games. Springer.Google Scholar
- Wayne Stahnke. 1973. Primitive binary polynomials. Mathematics of computation 27, 124 (1973), 977–980.Google Scholar
- Brett Stevens and Aaron Williams. 2014. The coolest way to generate binary strings. Theory of Computing Systems 54, 4 (2014), 551–577.Google ScholarDigital Library
- taotao54321. 2018. NES Dr.Mario hand simulator. https://gist.github.com/taotao54321/4ec019a251fdd8f9759fa8a8b5439559.Google Scholar
- Sam Trenholme. 2013. Alternate Pitfall maps. https://www.samiam.org/blog/20130617.html.Google Scholar
- Aaron Williams. 2019. Dr. Mario Puzzle Generation: Theory, Practice, & History (Famicom/NES). In The 22nd Japan Conference on Discrete and Computational Geometry, Graphs, and Games. 128–129.Google Scholar
- Aaron Williams. 2022. Nintendo’s Not-So-Random Sequence. https://gitlab.com/combinatronics/nintendos-not-so-random-sequence.Google Scholar
Index Terms
- Entropy Lost: Nintendo’s Not-So-Random Sequence of 32, 767 Bits
Recommendations
Classic Nintendo games are (computationally) hard
We prove NP-hardness results for five of Nintendo's largest video game franchises: Mario, Donkey Kong, Legend of Zelda, Metroid, and Pokémon. Our results apply to generalized versions of Super Mario Bros. 1-3, The Lost Levels, and Super Mario World; ...
Comments