Usage guide for the 2D/3D/4D Tetris project.
This is a 2D/3D/4D Tetris game written in Python. Currently, it contains a main launcher for the entire suite, dedicated 2D/3D/4D game launchers, Tutorials, and a Topology Explorer Playground, which is my main development effort right now.
python front.py — Root Wrapper, main launcher.
Use optional usage: front.py [--frontend {main,2d,3d,4d,front}] to get directly to 2d/3d/4d game modes.
Examples:
python front.py # launches main unified launcher
python front.py --frontend 4d # launches 4D mode directly
python front.py --mode 3d # alias formUse front.py --topology-playground [DIM] to launch the Topology Playground directly.
Examples:
python cli/front.py # normal game launcher
python cli/front.py --topology-playground # topology playground, dim 2
python cli/front.py --topology-playground 3 # topology playground, dim 3
python cli/front.py --topology-playground 4 # topology playground, dim 4
Boundary topology presets are available in setup menus:
bounded(default)wrap_allinvert_all
Gravity-axis wrapping is disabled by default on Game Mode. Topology explorer, available through the topology playground, enables full wrapping including the Y axis.

Advanced topology designer controls are available per mode:
Topology advanced(toggle)Topology profile(loaded fromconfig/topology/designer_presets.json)
- Python
3.11+(target compatibility includes3.14) - Development, local verification, CI, and packaging all use the editable-install contract from
pyproject.toml - Do not install legacy
pygamein the same environment - CI validation matrix: Python
3.11,3.12,3.13,3.14 - Desktop installers include embedded Python runtime (end users do not need system Python)
Bootstrap script (preferred):
cd .
scripts/bootstrap_env.sh
source .venv/bin/activatescripts/bootstrap_env.sh also installs the repo pre-push hook path
(.githooks/pre-push) so pushes run the local CI gate by default.
Manual setup uses the same editable-install contract:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -U pip
python -m pip install -e ".[dev]"
scripts/install_git_hooks.sh./scripts/verify.sh, ./scripts/ci_check.sh, and the GitHub workflows all assume the repo package is installed this way in the active environment.
- Canonical runtime source path is
src/tet4d/engine/. tet4d.engine.*is the canonical import path for runtime/tests/tools.- The repo expects an editable install for development and verification (
pip install -e ".[dev]"). - See
docs/MIGRATION_NOTES.mdfor structure history and shim removal milestones.
# Unified launcher via compatibility wrapper (kept stable)
python front.py
# Unified wrapper selector (routes to main/2d/3d/4d; default is "main")
# `front` is an alias for `main` (same target)
python front.py --frontend 4d
python front.py --mode 2d
# Canonical direct entrypoints (primary scripts)
python cli/front.py
# Direct modes (canonical cli forms; root wrapper supports --frontend/--mode)
python cli/front2d.py
python cli/front3d.py
python cli/front4d.py- Global menu navigation:
Esc/Backspace: go back (or exit current root menu)q: normalized as menu-back / escape in menu flows- Tiny profile aliases:
i/k/j/l-> up/down/left/right
- Tutorials are launched from the main launcher menu.
- Tutorial in-run hotkeys:
F5: previous stageF6: next stageF7: redo current stageF8: exit tutorial to menuF9: restart tutorial lesson
# macOS (.dmg)
bash packaging/scripts/build_macos.sh
# Linux (.deb)
bash packaging/scripts/build_linux.shWindows (PowerShell, .msi):
./packaging/scripts/build_windows.ps1Build artifacts are written to artifacts/installers/.
The Windows build produces a self-contained .msi with the payload cabinet
embedded, so install does not depend on a sibling cab1.cab file.
The canonical PyInstaller spec also pins lazy tet4d.ai.playbot.* modules as
hidden imports so frozen launcher/setup menus do not fail when playbot helpers
are loaded through package-level lazy exports.
The packaging scripts now smoke-run the freshly built packaged runtime with
--runtime-smoke-check under isolated user-data roots plus dummy SDL drivers
before emitting release artifacts, so frozen startup regressions fail the build
instead of shipping to installers.
Tag pushes matching v* also publish the generated installers through .github/workflows/release-packaging.yml.
Menu config:
config/menu/structure.jsonconfig/menu/defaults.jsonconfig/help/topics.jsonconfig/help/action_map.jsonconfig/topology/designer_presets.json
Runtime tuning:
config/gameplay/tuning.jsonconfig/gameplay/score_analyzer.jsonconfig/playbot/policy.jsonconfig/audio/sfx.json
Project-wide path/constants/security policy:
config/project/io_paths.jsonconfig/project/constants.jsonconfig/project/policy/manifests/secret_scan.json
User state:
state/menu_settings.jsonstate/topology/selected_profile.json(advanced topology export)state/analytics/leaderboard.jsonstate/tutorial/progress.jsonstate/analytics/score_events.jsonlstate/analytics/score_summary.json
Keybindings:
config/keybindings/defaults.jsonkeybindings/2d.jsonkeybindings/3d.jsonkeybindings/4d.json
Control/action icon renderer:
src/tet4d/ui/pygame/render/control_icons.pydraw_action_icon
ruff check .
ruff check --select C901 .
./scripts/check_editable_install.sh
python3 tools/governance/validate_project_contracts.py
python3 tools/governance/scan_secrets.py
python3 tools/governance/check_pygame_ce.py
pytest -q
PYTHONPATH=. python3 tools/stability/check_playbot_stability.py --repeats 20 --seed-base 0
python3 tools/benchmarks/bench_playbot.py --assert --record-trend
scripts/ci_check.sh
# Local quick parity run (quiet by default)
CODEX_MODE=1 ./scripts/verify.sh- Project structure and documentation:
docs/PROJECT_STRUCTURE.mddocs/FEATURE_MAP.mddocs/CONFIGURATION_REFERENCE.mddocs/USER_SETTINGS_REFERENCE.mddocs/GUIDELINES_RESEARCH.mddocs/RELEASE_INSTALLERS.md
- Usage:
README.md
- Workflow and product guidance:
docs/WORKFLOW_CODEX.mddocs/rds/
- Contract source:
config/project/policy_pack.json - Validator:
tools/governance/validate_project_contracts.py - Generated maintenance docs source data:
config/project/policy_pack.json - Generated config references:
docs/CONFIGURATION_REFERENCE.mdanddocs/USER_SETTINGS_REFERENCE.md(tools/governance/generate_configuration_reference.py) - Secret scanning policy/runtime scanner:
config/project/policy/manifests/secret_scan.json+tools/governance/scan_secrets.py
- If you install
pytestfrom local/offline wheels only, import can fail withModuleNotFoundError: No module named 'py'. - Workaround (offline/local wheel path): copy Homebrew shim file into the venv:
cp /opt/homebrew/lib/python3.11/site-packages/py.py .venv/lib/python3.14/site-packages/py.py
- Preferred path (when network is available): install
pytestfrom PyPI into the active.venv.
- Activate
.venvand verifypygame-ce(not legacypygame). - Ensure
ruffandpytestimport in.venv. - Run
scripts/ci_check.sh. - If it fails, run the individual checks listed in
Quality checksto isolate the failing stage.

