An endless turn-based RPG for the terminal CLI, implemented nine times with identical rules: Python, TypeScript, Rust, Elixir, C/C++, Go, Lua and Assembly - Built with ClaudeCode Opus 5.5
This project started in 2016 as my first Python program to learn object-oriented programming, got a TypeScript version in 2022 to learn TypeScript, and in 2026 it became a didactic monorepo: the same game written in Python, TypeScript, Go, Rust, Elixir, C++, C and Lua, side by side, with the same architecture, the same data and tests that prove the eight implementations behave exactly the same. A ninth one, in x86-64 Assembly, exists for teaching: the same engine, proven by the same golden files, with a simple line-based interface (docs/asm.md).
- Pick a vocation (Warrior, Archer or Mage), a difficulty (Easy, Normal, Hard) and a language (English or Português)
- Fight an endless sequence of monsters in tiers of increasing power, with a boss every 10 rounds
- Visit the merchant after every fight: potions, selling loot, a rotating stock
- Loot common, rare, epic and legendary equipment for 8 slots with random affixes: attack, crit, spell power, elemental protections, dodge, parry, leech…
- Spells level up the more you use them (level 2 after 20 casts, level 3 after 50)
- Status effects, elemental weaknesses and bosses that telegraph their strongest attacks
- Animated ASCII monsters, HP/MP bars, auto-save, run history, bestiary, achievements and Hall of Fame
- Seeded runs (
--seed) reproducible across the eight languages
Monster, boss, item and spell names are inspired by Tibia (via TibiaWiki); all stats and ASCII art are original. This is a non-commercial, educational project and is not affiliated with CipSoft.
Recorded from the Go version (--seed 42, Warrior, Normal); the other seven versions render the same layout from the
same UI controller. The GIFs are generated by VHS tapes in
scripts/gameplay/: run bash scripts/record-gameplay.sh (Docker) to record them again.
Starting a run: language, title screen, difficulty, name, vocation and auto-equip.
A regular fight: attack, the spell list, defend, a health potion, then auto-battle.
A boss fight: the tier 1 boss telegraphs its charged attack; auto-battle finishes it.
Between fights: the merchant, equipment, character sheet, merchant stock and potion shop.
| Implementation | Language / runtime | TUI | Quality |
|---|---|---|---|
rpg-python (reference) |
Python 3.14 + uv | Textual | Ruff, mypy, pytest |
rpg-typescript |
TypeScript 7 + Bun 1.4.2 (single-file executable) | Ink | Biome, tsc, bun:test |
rpg-golang |
Go 1.27 (executable) | Bubble Tea | gofmt, golangci-lint, go test |
rpg-rust |
Rust 1.99, edition 2024 (executable) | ratatui + crossterm | rustfmt, clippy, cargo test, cargo-llvm-cov |
rpg-elixir |
Elixir 1.20 + Erlang/OTP 29 (escript), no Hex dependencies | hand-written ANSI renderer | mix format, ExUnit, mix test --cover |
rpg-cpp |
C++23 + CMake and Ninja (executable) | FTXUI | clang-format, -Werror, Catch2 + ctest, llvm-cov |
rpg-c |
C17 + CMake and Ninja (executable), no third-party libraries | hand-written ANSI renderer | clang-format, -Wall -Wextra -Wpedantic -Werror, in-tree test harness + ctest |
rpg-lua |
Lua 5.5 (interpreter compiled into the executable) + a small C host built with CMake, no Lua libraries | hand-written ANSI renderer | StyLua, luacheck, in-tree test harness + ctest |
rpg-asm (engine + text UI) |
x86-64 Linux NASM 2.16 + libc, built and run in Docker | line-based text UI | golden replay, bot parity and simulator diff in the image build |
shared |
JSON data, i18n, ASCII art, golden files | — | JSON Schema |
Pick the script for your system and implementation. Each one checks the toolchain, installs dependencies and starts the game:
git clone https://github.com/AlexGalhardo/CLI-Turn-Based-RPG-Game.git
cd CLI-Turn-Based-RPG-Game
bash setups/play-on-unix-version-python.sh # or any script from the table aboveNo toolchain? Download a ready-to-run TypeScript, Go, Rust or C++ executable for Linux x64, macOS arm64 or Windows x64
(Lua: Linux x64 and Windows x64) from the latest release (checksums in
SHA256SUMS.txt). On macOS/Linux, chmod +x it first. The release also ships the Elixir escript, a single file that
runs anywhere Erlang/OTP is installed (escript rpg-elixir on Windows).
Only Docker is needed: every implementation has a Dockerfile and a service in compose.yml
(python, typescript, golang, rust, elixir, cpp, c, lua, asm).
docker compose run --rm python # builds the image on first use, then plays
docker compose run --rm rust --seed 42 --lang pt-BR # game flags go after the service name
docker compose run --rm -T golang --simulate 100 # no TTY for non-interactive outputSaves, history and profile are kept in the saves volume, shared by all services (the formats are the same, so a
run started in one language continues in another). docker compose down -v deletes them.
Use a terminal of at least 100 × 30. Useful flags (same in the eight versions): --seed 42, --lang pt-BR,
--no-anim, --simulate 1000.
# Python (reference)
cd rpg-python && uv sync && uv run rpg
uv run ruff format && uv run ruff check && uv run mypy && uv run pytest
# TypeScript
cd rpg-typescript && bun install && bun run dev
bun run lint && bun run typecheck && bun test && bun run build
# Go
cd rpg-golang && go generate ./... && go run ./cmd/rpg
go vet ./... && go test -race ./... && go build -o bin/rpg-golang ./cmd/rpg
# Rust
cd rpg-rust && cargo run --release
cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test && cargo build --release
# Elixir
cd rpg-elixir && mix run -e 'System.halt(Rpg.Main.run(System.argv()))'
mix format --check-formatted && mix compile --warnings-as-errors && mix test --cover && mix escript.build
# C++
cd rpg-cpp && cmake --preset release && cmake --build --preset release && ./build/release/rpg-cpp
cmake --preset debug && cmake --build --preset debug && ctest --preset debug
# C
cd rpg-c && cmake --preset release && cmake --build --preset release && ./build/release/rpg-c
cmake --preset debug && cmake --build --preset debug && ctest --preset debug
# Lua (the build compiles the Lua 5.5 interpreter and the C host into one executable)
cd rpg-lua && cmake --preset release && cmake --build --preset release && ./build/release/rpg-lua
cmake --preset debug && cmake --build --preset debug && ctest --preset debug
# Assembly (x86-64 Linux; the image build assembles, links and runs the parity tests)
docker build -f rpg-asm/Dockerfile -t rpg-asm . && docker run --rm -it rpg-asm --seed 42The docs/ folder explains the project by area (it is also the context used by AI agents, through
AGENTS.md). The roadmap is in PLAN.md.
- Architecture
- Game design — rules and formulas
- Cross-language parity
- Shared data format
- Persistence
- Terminal UI
- Testing
- CI/CD and versioning
- Docker
- Architecture decision records
- Implementation guides: Python · TypeScript · Go · Rust · Elixir · C++ · C · Lua · Assembly
Contributions are welcome. Read CONTRIBUTE.md: commits follow
Conventional Commits (checked by commitlint), versions follow
SemVer and every commit on main is its own release, described in
CHANGELOG.md (Keep a Changelog). CI blocks on formatting, lint, types, tests and builds of
the eight implementations.
Created by Alex Galhardo. Distributed under the MIT license.



