A Python implementation of the Blokus game engine following the project's Hexagonal (Ports & Adapters) architecture. The project provides a console (CLI) player and an optional local web GUI powered by FastAPI + Uvicorn.
Implementation language: Python (managed with uv). See AGENTS.md for coding-agent context and developer commands.
These steps assume a fresh clone of the repository. Recommended: use a Python virtual environment.
- Create and activate a virtual environment (Windows example):
python -m venv .venv
.\.venv\Scripts\Activate.ps1 # PowerShell
# or (cmd): .\.venv\Scripts\activateBootstrap pip in the venv (if needed)
Some Python installations or freshly created virtual environments may not include pip by default. If you see errors like "No module named pip" or later see "uv missing", bootstrap pip before installing other packages.
# In the activated venv, try ensurepip first (preferred)
python -m ensurepip --upgrade
python -m pip install --upgrade pip setuptools wheel
# If ensurepip is not available, use get-pip.py as a fallback
curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
rm get-pip.py
# Prefer 'python -m pip' so the pip used matches the active interpreter
python -m pip --version- Install
uv(project task runner) and sync dependencies:
# Option A — install into the active venv
python -m pip install --upgrade pip
python -m pip install uv
# Option B — install uv with pipx (keeps it isolated from the venv)
pipx install uv
# Then sync project dependencies defined in pyproject.toml
uv sync- Verify tests run:
uv run pytestCLI (console) mode — plays in the terminal
uv run python -m app
# or, if you have installed the package entrypoint in the active environment:
uv run blokus-engineWeb GUI mode — starts a local FastAPI server and serves the browser UI
uv run python -m app --gui
# or (installed entrypoint):
uv run blokus-engine --guiOpen your browser at: http://127.0.0.1:8000
Play Blokus Duo (14x14, 2 players) with the GUI or CLI by adding --duo:
uv run python -m app --gui --duoNotes on commands
- The correct wrapper is
uv run .... Do NOT runpython -m uv run ...— that invocation is incorrect and will fail. If theblokus-enginescript entrypoint is not installed into your environment, useuv run python -m appinstead. - If you prefer to run the web server directly (without
uv), you can runpython -m src.web_mainfrom a configured environment that putssrc/onPYTHONPATH, but usinguv run python -m app --guiis the supported, reproducible path.
-
I only see console output and no browser UI: you likely started the CLI (no
--guiflag) or used the wronguvinvocation. Re-run withuv run python -m app --gui. -
Server not reachable at http://127.0.0.1:8000: check the terminal where you started the app — Uvicorn logs should show the server URL (look for "Uvicorn running on http://127.0.0.1:8000"). If port 8000 is in use, edit
src/web_main.pyand change theport=argument passed touvicorn.run(...), then restart. -
If you see the following error after running
uv run pytest: ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --cov=src --cov-report=term-missing --cov-report=xml --cov-fail-under=85 This meanspytest-covis not installed. Fix it by running:
uv add --dev pytest-cov-
Missing dependencies / import errors: ensure
uv synccompleted successfully and that you activated the venv before running commands. If you installeduvglobally withpipx, ensure you still activate the project venv when running Python module commands. -
Static UI not loading or template errors: verify
src/static/andsrc/templates/game.htmlexist. The FastAPI orchestrator mounts/staticand servesgame.htmlat/.
- Feature branch per feature. Merge to
mainvia Pull Request; delete feature branch after merge. - Follow the project's Architectural invariants in AGENTS.md and design documents in the
design/folder.
The GitHub Actions workflow runs on every push and enforces the same quality gates used locally.
Run these commands before pushing:
uv run ruff check .
uv run ruff format --check .
uv run mypy src tests
uv run pytest- Design & architecture decisions: design/ADR.md
- Project spec: specifications/SPEC_M1.md
- Agent/context notes: AGENTS.md
# Create venv (Windows PowerShell shown)
python -m venv .venv
.\.venv\Scripts\Activate.ps1
# Install uv (either in venv or with pipx)
pip install uv
# or
pipx install uv
# Sync project deps
uv sync
# Run tests
uv run pytest
# Run CLI
uv run python -m app
# Run web GUI
uv run python -m app --guiAll relevant md files that are to be turned in and graded can be found in the deliverables folder
- Requirements: All
- Design: Richard + Denis
- Coding: Petar + Iven
- Testing: Petar + Iven
- Debugging: Denis + Iven
- Reviewing : Richard