No Blockers: Building Tetris through Prompt Engineering

N

Can the worlds favorite AI match 1980’s soviet engineering?

I recently watched the just-released biographical drama film ‘Tetris,’ starring Taron Egerton, which depicts the true story behind the creation, licensing, and distribution of the iconic pattern-matching survival game. Long story short, the Soviet game designer Alexey Pajitnov built Tetris largely on his own while at the Dorodnitsyn Computing Centre in Moscow using a soviet-built Elektronika 60.

The Elektronika 60 was a mainframe computer used primarily for scientific and engineering applications, and unsurprisingly, not game development. The system had no way to display raster graphics so it relied on text-based representations for the games “tetrominos” – the iconic polygonal moving shapes.

The technical undertaking of building Tetris in these circumstances is incredible, but the execution from ideation, the idea, to product is the true genius. There isn’t a LLM on earth that could come up with an original idea like Tetris. It took a pro to build it and a creative genius to ideate it – Alexey happened to be both.

As an experiment, I wanted to see if I could create an implementation of Tetris written entirely in pascal (just like the original) in a short period of time (< 2hrs) using the assistance of ChatGPT. Keep in mind, I’m a career programmer, so I’ve got that going for me, but I’ve never written a line of pascal in my life. So what’s the verdict? Could I throw something together with ChatGPT riding shotgun driving.

Sorta.

In terms of prompt-engineering, you can’t just ask for a working Tetris game in pascal, trust me I tried. One helpful prompt to get started was to have ChatGPT first describe the required implementation steps needed to build a game like Tetris then ask it to build out each of those steps in a “vacuum”. Once you have the individual components you can ask it to combine them. I also had ChatGPT walk me through the steps required to actually compile pascal code on my M1 Mac; this was much faster than Googling the steps.

Here’s the code posted to my GitHub account. Take a look at it, compile it, run it; it’s obviously Tetris, or at least inspired by it, but it’s not good. This leads to an important point when discussing the current state of LLM-assisted software development: the fact that I can use a service like ChatGPT to deliver a *mostly* working version of Tetris written in a programming language I’ve only ever heard of in less than two hours is incredible – but you still need an expert to deliver you that final 20% (or more) for it to be a stable and engaging product… for now.

As for the code I posted – If you’re curious enough to actually build and run it and/or you happen to be a Pascal Pro™ please feel free to fork the repo and open a pull request.

Oh and just so we’re clear, the scoreboard:
Alexey Pajitnov: 1
ChatGPT: 0

About the author

John Solsma
By John Solsma

John Solsma

Get in touch

John is a Senior Engineering Manager and iOS Solution Architect with 10 years experience writing mobile apps. He's developed iOS apps for clients such as Apple and AT&T and developed one of the worlds first direct-to-device esim-installation apps. He attended the University of Iowa for Computer Science and recently graduated from the University of Texas AI and Machine learning graduate program.