Arhan Chaudhary's "Corrupted Pong" Is a Block-Breaker That Destroys Its Own Memory
What happens if a simulated computer plays a game in which the target is a chunk of its own memory? Some interesting stuff, it seems.
Computer science and electrical computer engineering student Arhan Chaudhary has built a block-breaker game unlike any others: the "blocks" are actually chunks of the computer's memory, and they're overwritten as they're destroyed β leading to some interesting behavior before the eventual crash.
"Two years ago, I made NAND, a 16-bit computer made entirely from NAND gates emulated on the web," Chaudhary explains. "NAND features its own custom CPU architecture, virtual machine, programming language, compiler, and IDE, and it is based on the Jack-VM-Hack platform specified in the nand2tetris course. A few weeks ago during the height of my midterms I had a crazy idea: what if we allocated memory on the screen instead of on the heap?"
As a proof of concept, Chaudhary started with a simple "Hello, World" program that worked on screen memory rather than the heap β and output a visual representation of said memory, before overwriting a chunk with its textual message. As the program then immediately quits, there were no ill-effects β so Chaudhary followed up by creating a hole-in-the-wall block-breaker game that would run continuously, after disabling invalid-instruction capture to prevent early crashes.
The result: a block-breaker where the player's ball pushes through a visual representation of memory, corrupting it as it goes. Naturally, this results in some interesting behavior depending on exactly that memory portions are affected: using one starting offset the ball appears to "teleport" around the playfield; in another it moves in seemingly random directions; yet another causes an almost-immediate crash with severe display corruption. "You invoked undefined behavior," Chaudhary guesses of what caused the latter. "NAND invoked Cthulhu."
More information on the project is available on Chaudhary's blog; the program, and the virtual machine on which it runs, can be loaded in-browser for your own experimentation on the NAND website under the program name "CorruptedPong."