Skip to content

A classic Tetris game developed in Go for the console, with 95% of the code generated by LLM.

License

Notifications You must be signed in to change notification settings

plar/llm-tetris

Repository files navigation

LLM Tetris Console Game

Context and Motivation

This is a classic Tetris game developed in Go, designed to run in a console environment. The project took about three hours to complete from scratch. This project has ~50% test coverage and can be used as a good starting point for further LLM exploration. It has own issues and flows that can be improved be senior developers. :) It was created as a fun project to showcase the capabilities of modern LLMs in generating code.

I’ve been using this approach for about a year (with my own prompts and tools), and recently, Harper Reed explained it quite well. I decided to showcase his method(prompts) with this project to demonstrate its potential to a wider audience.

Why Tetris?

Tetris has long been a popular choice for developers as a test project when exploring new programming languages, offering a perfect blend of complexity and enjoyment. Throughout my career, I've created approximately 20 different versions of Tetris, utilizing various languages. It is time of ChatGPT to create a new version of Tetris. :)

LLM-Tetris

Used tools

  • Go
  • VSCode with continue.dev extension + ChatGPT4o (paid)
  • ChatGPT for initial prompts

All Chat sessions can be found in the chats folder. This folder contains all the prompts and responses from ChatGPT and continue.dev.

Installation

Run from Source

You need to have Go installed on your system. You can download it from the Go website.

Clone the repository: $ git clone https://github.com/plar/llm-tetris.git

Navigate to the project directory: $ cd llm-tetris

Run the game: $ go run .

Build from Source

Compile for Different Platforms

Run the following commands in your terminal to build binaries for each target platform:

For Linux

GOOS=linux GOARCH=amd64 go build -o tetris

For Windows

GOOS=windows GOARCH=amd64 go build -o tetris.exe

For macOS

GOOS=darwin GOARCH=amd64 go build -o tetris

Usage

Run the game by executing the binary:

On Windows

tetris.exe

On Linux/macOS

./tetris

Controls

  • Move Left: Left Arrow
  • Move Right: Right Arrow
  • Soft Drop: Down Arrow
  • Rotate Clockwise: Up Arrow
  • Hard Drop: Spacebar
  • Pause: P

Configuration

The game supports configuration through a JSON file config.json:

  • Key remapping: Adjust the keys for game controls.

Upon the first run, a default config.json file will be generated if one doesn't exist.

Persistence

High scores are stored in config.json and persist across game sessions.

License

This project is licensed under the MIT License.

About

A classic Tetris game developed in Go for the console, with 95% of the code generated by LLM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages