Skip to content
franklixuefeiPublic

About

a Tetris-like game, with GUI implemented with X11 library.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Quadris

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 just 4lef). Drop it with drop. Rotate with clockwise. 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.


Features

  • 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), or null (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 heuristic and a non-deterministic stochastic "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.

Quick start

Windows (Visual Studio 2022/2026 toolchain)

cmake --preset windows-debug
cmake --build out/build/windows-debug
ctest --preset windows-debug
.\out\build\windows-debug\quadris.exe

Or just File → Open → Folder… in Visual Studio, set quadris as the startup item, and press F5.

Linux / macOS

cmake --preset linux-debug
cmake --build out/build/linux-debug
ctest --test-dir out/build/linux-debug
./out/build/linux-debug/quadris

Then 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

Documentation

  • 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.

Project layout

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

Heritage

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.

About

a Tetris-like game, with GUI implemented with X11 library.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages