Randomly Generating Atari Games

They say that if you let a million monkeys type on a million typewriters, they will eventually write the works of Shakespeare. While not quite the same thing [bbenchoff] (why does that sound familiar?), spent some computing cycles to generate random data and, via heuristics, find valid Atari 2600 “games” in the data.

As you might expect, the games aren’t going to be things you want to play all day long. In fact, they are more like demos. However, there are a number of interesting programs, considering they were just randomly generated.

Part of the reason this works is that the Atari has a fairly simple 6502-based CPU, so it is straightforward to evaluate the code, and a complete game fits in 4 K. Still, that means there are, according to [Brian], 1010159 possible ROMs. Compare that to about 1080 protons in the visible universe, and you start to see the scale of the problem.

To cut down the problem, you need some heuristics you can infer from actual games. For one thing, at least 75% of the first 1K of a ROM should be valid opcodes. It is also easy to identify code that writes to the TV and other I/O devices. Obviously, a program with no I/O isn’t going to be an interesting one.

Some of the heuristics deal with reducing the search space. For example, a valid ROM will have a reset vector in the last two bytes, so it is possible to generate random data and then apply the small number of legal reset vectors.

Why? Do you really need a reason? If you don’t have a 2600 handy, do like [Brian] and use an emulator. We wonder if the setup would ever recreate Tarzan?

25 thoughts on “Randomly Generating Atari Games

  1. I wonder how results of this effort would compare on a more traditional “computer”. The 2600 TIA – Television Interface Adapter (video generator chip) is a bit of a unique animal having no buffer memory and generating a line of video just at the exact time it needs to be traced out on the CRT.

    There have a number of TIA tricks discovered over the many ensuing years since the original release of the 2600. I have wondered whether any new ones could be discovered via random code generation.

    1. To me, Benchoff is classic HaD voice, but tbh the site has been more consistent and less fighty since he left. Alas there can only be one HaD, not two, one which is a steady stream of awesome, and one which is more erratic with lots of controversy

      1. Yeah he was the only regularly contributing writer for a while before the Supply Frame buy out. I don’t think this site would still be here without him. Some of the flame wars he’d get into with readers in the comments were pretty bonkers.

  2. Technically the infinite number of monkeys with an infinite number of typewriters did come up with the complete works of Shakespeare. The time taken would be indeterminate – basically any time between zero years and infinity years – and statistically it’s possible that the first primate with the first typewriter could actually have done it. As it turned out, we only needed 85 million years, and the typewriter wasn’t necessary.

    1. Starting from scratch, it was coming up with a place for the monkeys to live that was really the hardest part, followed by making the monkeys; the works of Shakespeare came relatively quickly after all that was sorted out.

    1. yea even back in the day when geniuses hand crafted the best they could do … how long are you really going to play atari? an entire games once mastered could last 5 min before looping and just speeding crap up

  3. I would rather see an LLM, trained on the blurbs from the back of the boxes and the code in the ROMs, that could generate an Atari game from a text description.

  4. I’ve given a similar idea a lot of thought (probably too much) over the years. You could basically create every possible application possible for a given memory size via brute force. The code would be easy, the problem is the amount of time it would take to calculate every bit combination of 2,048 bytes (16, 384 bits). That would be counting from 0 to 2^16,384 (1.189731495357231765085759326628e+4932). Let’s just say it won’t happen in my lifetime without something like Quantum computers. You could optimize away a lot of it (all 0, all 1, etc…), but you still have to test the results as well (Ya Emulators!). The majority of the results would be garbage, but you’ll eventually come to the value that IS Pitfall and a value that is a Word Processor on the Atari 2600 (if you can do it in 2K or less).

    Now maybe an LLM could look for patterns of bits in all the existing games and figure a better way to optimize it.

    Just a fun thought :)

  5. There’s no generic algorithm, just random nose based on a few rules. It’d be cool to take it to the next level and iteratively evolve new, random games. See what it comes up with.

    Of course, once you add human playtesting into the loop, you’re basically just turning the testers into unconscious game designers.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.