skip to main content
10.1145/3555858.3563265acmotherconferencesArticle/Chapter ViewAbstractPublication PagesfdgConference Proceedingsconference-collections
research-article

Entropy Lost: Nintendo’s Not-So-Random Sequence of 32, 767 Bits

Published:04 November 2022Publication History

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.

References

  1. 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 ScholarGoogle ScholarCross RefCross Ref
  2. Abbas M Alhakim. 2010. A simple combinatorial algorithm for de Bruijn sequences. The American Mathematical Monthly 117, 8 (2010), 728–732.Google ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle Scholar
  4. Internet Archive. 2020. [No-Intro] Nintendo - Nintendo Entertainment System. https://archive.org/details/nointro.nes.Google ScholarGoogle Scholar
  5. John Aycock. 2016. Retrogame Archeology: Exploring Old Computer Games (1st ed.). Springer, New York, NY, USA.Google ScholarGoogle ScholarCross RefCross Ref
  6. Pradipto Banerjee and Michael Filaseta. 2010. On a polynomial conjecture of Pál Turán. Acta Arith 143, 3 (2010), 239–255.Google ScholarGoogle ScholarCross RefCross Ref
  7. John Adrian Bondy, Uppaluri Siva Ramachandra Murty, 1976. Graph theory with applications. Vol. 290. Macmillan London.Google ScholarGoogle Scholar
  8. Ben Cameron, Aysu Gündoğan, and Joe Sawada. 2022. Cut-Down de Bruijn Sequences. arXiv preprint arXiv:2205.02815(2022).Google ScholarGoogle Scholar
  9. Joseph DiMuro. 2019. Classifying rotationally-closed languages having greedy universal cycles. The electronic journal of combinatorics26 (2019), P1.35. Issue 1.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarCross RefCross Ref
  11. 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 ScholarGoogle Scholar
  12. Michael Filaseta. 2014. Is Every Polynomial with Integer Coefficients Near an Irreducible Polynomial?Elemente der Mathematik 69, 3 (2014), 130–143.Google ScholarGoogle Scholar
  13. Michael Filaseta and Michael Mossinghoff. 2012. The distance to an irreducible polynomial, II. Math. Comp. 81, 279 (2012), 1571–1585.Google ScholarGoogle ScholarCross RefCross Ref
  14. 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 ScholarGoogle ScholarCross RefCross Ref
  15. Daniel Gabric and Joe Sawada. 2022. Investigating the discrepancy property of de Bruijn sequences. Discrete Mathematics 345, 4 (2022), 112780.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarCross RefCross Ref
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle Scholar
  19. Solomon W. Golomb. 1981. Shift Register Sequences(1 ed.). Aegean Park Press.Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Thomas Jentzsch. 2017. Pitfall!x256 (was: Pitfall!x16). https://atariage.com/forums/topic/267046-pitfallx256-was-pitfallx16.Google ScholarGoogle Scholar
  23. Donald E Knuth. 2005. The Art of Computer Programming, Volume 4, Fascicle 2: Generating All Tuples and Permutations. Addison-Wesley Professional.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle Scholar
  26. Monroe H Martin. 1934. A problem in arrangements. Bull. Amer. Math. Soc. 40, 12 (1934), 859–864.Google ScholarGoogle ScholarCross RefCross Ref
  27. 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 ScholarGoogle Scholar
  28. Mike Mika. 2013. Why I hacked Donkey Kong for my daughter. Wired, March 11(2013).Google ScholarGoogle Scholar
  29. Nick Montfort and Ian Bogost. 2009. Racing the beam: The Atari video computer system. Mit Press.Google ScholarGoogle Scholar
  30. Nick Morgan. 2012. Easy 6502 Simulator. https://skilldrick.github.io/easy6502/simulator.html.Google ScholarGoogle Scholar
  31. Trang Q. Ngo. 2020. Python implementation of Dr. Mario algorithms. https://github.com/trangqngo/Dr-Mario-virus-generation.Google ScholarGoogle Scholar
  32. nightmareci. 2012. Dr. Mario virus placement. https://tetrisconcept.net/threads/dr-mario-virus-placement.2037.Google ScholarGoogle Scholar
  33. nightmareci. 2013. Dr. Mario. https://tetris.wiki/Dr._Mario.Google ScholarGoogle Scholar
  34. Robert Xiao (nneonneo). 2015. bgrep. https://github.com/nneonneo/bgrep.Google ScholarGoogle Scholar
  35. Frank Ruskey, Carla Savage, and Terry Min Yih Wang. 1992. Generating necklaces. Journal of Algorithms 13, 3 (1992), 414–430.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. 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 ScholarGoogle ScholarCross RefCross Ref
  37. 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 ScholarGoogle Scholar
  38. Joe Sawada, Aaron Williams, and Dennis Wong. 2016. A surprisingly simple de Bruijn sequence construction. Discrete Mathematics 339, 1 (2016), 127–131.Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. Noor Shaker, Julian Togelius, and Mark J Nelson. 2016. Procedural content generation in games. Springer.Google ScholarGoogle Scholar
  41. Wayne Stahnke. 1973. Primitive binary polynomials. Mathematics of computation 27, 124 (1973), 977–980.Google ScholarGoogle Scholar
  42. Brett Stevens and Aaron Williams. 2014. The coolest way to generate binary strings. Theory of Computing Systems 54, 4 (2014), 551–577.Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. taotao54321. 2018. NES Dr.Mario hand simulator. https://gist.github.com/taotao54321/4ec019a251fdd8f9759fa8a8b5439559.Google ScholarGoogle Scholar
  44. Sam Trenholme. 2013. Alternate Pitfall maps. https://www.samiam.org/blog/20130617.html.Google ScholarGoogle Scholar
  45. 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 ScholarGoogle Scholar
  46. Aaron Williams. 2022. Nintendo’s Not-So-Random Sequence. https://gitlab.com/combinatronics/nintendos-not-so-random-sequence.Google ScholarGoogle Scholar

Index Terms

  1. Entropy Lost: Nintendo’s Not-So-Random Sequence of 32, 767 Bits

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Other conferences
        FDG '22: Proceedings of the 17th International Conference on the Foundations of Digital Games
        September 2022
        664 pages
        ISBN:9781450397957
        DOI:10.1145/3555858

        Copyright © 2022 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 4 November 2022

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
        • Research
        • Refereed limited

        Acceptance Rates

        Overall Acceptance Rate152of415submissions,37%
      • Article Metrics

        • Downloads (Last 12 months)23
        • Downloads (Last 6 weeks)4

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      HTML Format

      View this article in HTML Format .

      View HTML Format