A Tetris-like puzzle game you control by typing commands — written in 2013 for Linux/X11, now modernized into a clean, cross-platform C++17 project with pluggable display backends.
+--------------------+
| . . . . . . .|
| . . [T][T][T] . .|
| . . . [T] . . .|
|[I][I][I][I][O][O] .|
+--------------------+
Score: 140 Level: 2 Next: S
Move a block four squares left with
4left(or just4lef). Drop it withdrop. Rotate withclockwise. The display is just a window onto the action — so the same game runs in a colour terminal, a native Windows window, or the original X11.
- Runs everywhere — Windows, macOS, Linux. No third-party dependencies for the default build.
- Pluggable rendering — choose a backend at runtime:
console(default, ANSI colour),gdi(native Win32 window),x11(the original, on Linux), ornull(headless). - Clean, layered architecture — pure game core, separated game loop, and an I/O boundary built on small interfaces (SOLID, dependency injection).
- Memory-safe — value types, smart pointers, a single contiguous board allocation; verified clean under AddressSanitizer.
- Watch it play itself — a pluggable solver with two brains: a deterministic
heuristicand a non-deterministicstochastic"AI". Just add--solver. - Tested — 36 unit + integration tests, wired into CTest and Visual Studio Test Explorer.
- Faithful gameplay — the shapes, levels, scoring, RNG, and command language are preserved from the original.
cmake --preset windows-debug
cmake --build out/build/windows-debug
ctest --preset windows-debug
.\out\build\windows-debug\quadris.exeOr just File → Open → Folder… in Visual Studio, set quadris as the startup
item, and press F5.
cmake --preset linux-debug
cmake --build out/build/linux-debug
ctest --test-dir out/build/linux-debug
./out/build/linux-debug/quadrisThen type help in the game for the full command list. Or sit back and watch
the built-in AI play it:
quadris --solver # AI plays in the terminal
quadris --solver --backend gdi # AI plays in a native window- docs/manual.md — how to play: controls, levels, scoring, backends, the auto-play solver, building, and the Visual Studio walkthrough.
- docs/architecture.md — the design: layering, the pluggable renderer, SOLID, dependency injection, the memory model, and the pluggable solver, with before/after comparisons to the original code.
src/
core/ Pure game logic — Board, Tetromino, Rng, Scoring, SpawnPolicy (no I/O)
game/ Game loop + command parsing (Trie, CommandParser) + GameView port
io/ Renderer/InputSource interfaces + Console/GDI/X11/Null backends
solver/ Auto-play AI — Policy strategy + Heuristic/Stochastic brains
app/ main() — the composition root
tests/ Unit + integration tests (dependency-free harness)
docs/ Manual and architecture guide
assets/ sequence.txt (the level-0 block sequence)
UML/ The original 2013 design diagram
legacy/ The original 2013 source, preserved for reference
Quadris began as a 2013 C++ course project: a command-driven Tetris with an X11
GUI. The original source is preserved under legacy/ and its design
diagram under UML/. This modernization keeps the gameplay intact while
rebuilding the structure for portability, clarity, and extensibility — see
docs/architecture.md for the full story.