Cross-platform Python tool that reads Halo 2 multiplayer post-game statistics from Xbox/Xemu via XBDM or QMP. Linux-compatible alternative to Windows-only HaloCaster.
Stats captured: Kills, deaths, assists, suicides, K/D ratio, accuracy (shots/hits/headshots), medals, placement, team data, and gametype-specific stats across all game modes (Slayer, CTF, Oddball, KOTH, Juggernaut, Territories, Assault).
main is the production branch. It includes relocatable xemu/QMP reads for the active game-variant name, map metadata fallbacks, and the shared agent/master snapshot schema. Experimental memory research belongs under research/ or on a feature branch and should not replace main without passing the regression suite.
- Python 3.7+ (no pip dependencies for core tool)
- One of:
- Xbox with XBDM enabled (debug kit or modded console with CerbiosDebug)
- Xemu with QMP enabled (launch with
-qmp tcp:0.0.0.0:4444,server,nowait)
Run watch mode in the background during your session. It auto-detects game completions and saves stats after each match:
QMP (Xemu) — primary method:
python halo2_stats.py --host <XEMU_IP> --qmp 4444 --watchRequires Xemu launched with -qmp tcp:0.0.0.0:4444,server,nowait.
XBDM (Xbox/Xemu with CerbiosDebug):
# Polling (checks every 3 seconds)
python halo2_stats.py --host <XBOX_IP> --watch
# Instant detection via breakpoint (no polling delay)
python halo2_stats.py --host <XBOX_IP> --watch --breakpointEach completed game is automatically deduplicated and saved as JSON to the history/ directory.
Start the built-in web viewer to browse your game history:
python pgcr_server.pyOpen http://localhost:8080 in your browser. The viewer reads all saved games from history/ and displays them with scores, placements, and per-player breakdowns.
To use a different port: python pgcr_server.py 9090
All game data is saved to the history/ directory as JSON files, one per game:
history/
2026-02-18_22-31-58_cf561ec1.json
2026-02-18_21-59-26_bc2c035c.json
...
Each file is named <date>_<time>_<fingerprint>.json and contains the full scoreboard: every player's stats, team data, and gametype. These files are consumed by the web viewer and the export scripts.
# Default: rich scoreboard with accuracy, medals, gametype stats
python halo2_stats.py --host <IP> --save
# Simple K/D/A summary
python halo2_stats.py --host <IP> --simple
# PGCR tabular format (matches in-game screenshot layout)
python halo2_stats.py --host <IP> --pgcr
# JSON output (to stdout)
python halo2_stats.py --host <IP> --json
# JSON output to a specific file
python halo2_stats.py --host <IP> --json --output stats.json| Flag | Description |
|---|---|
--port N |
XBDM port (default: 731) |
--poll N |
Poll every N seconds without watch mode (0 = single read) |
--watch-interval N |
Seconds between watch-mode polls (default: 3) |
--breakpoint, -b |
Use XBDM breakpoint for instant game-end detection instead of polling |
--history-dir DIR |
Directory for auto-saved games (default: history/) |
--pgcr-display |
Also read killed-by data from PGCR display (post-game screen only) |
--timeout N |
Connection timeout in seconds (default: 5) |
--slow |
200ms read delay instead of 50ms (XBDM only, safer for unstable connections) |
--save-ram |
Save full 64MB RAM snapshot at game end (QMP only, large files) |
--verbose |
Debug logging |
# Test XBDM
python xbdm_client.py <XBOX_IP>
# Test QMP
python qmp_client.py <XEMU_IP> 4444Export scripts require additional dependencies:
pip install -r exports/requirements.txt# PostgreSQL
python exports/db_export.py --init-schema
python exports/db_export.py --import-history
# Excel
python exports/xlsx_export.py --history-dir history/ -o halo2_stats.xlsx
# Per-game Excel sheets (Bungie-style)
python exports/xlsx_export.py --per-game --style bungie -o exports/bungie/StatsBorg can also run as a central ingest server backed by PostgreSQL. This is for collecting matches from multiple game boxes into one shared database while letting contributors build different frontends from the same source.
cp .env.example .env # or set POSTGRES_PASSWORD and MASTER_TOKEN another way
docker compose -f docker-compose.master.yml up -d --build
curl http://127.0.0.1:8080/healthzThe master service binds to 127.0.0.1:8080 by default. Put a TLS reverse proxy
in front of it before exposing it publicly, because agents send MASTER_TOKEN
as a bearer token.
Agent ingest endpoint:
POST http://127.0.0.1:8080/api/v1/matches
Authorization: Bearer <MASTER_TOKEN>Read APIs include /api/games, /api/players, /api/leaderboard/<stat>,
/api/pvp?player=<name>, and /api/v1/servers.
halo2_stats.py Main CLI tool
xbdm_client.py XBDM protocol client
qmp_client.py QMP protocol client
halo2_structs.py Data structures and struct parsing
addresses.json Memory address reference
pgcr_server.py Web viewer server
pgcr_viewer.html Browser-based game history viewer
history/ Saved game data (JSON, one file per game)
exports/ PostgreSQL and Excel export scripts
Run the dependency-free regression suite before deploying:
python3 -m unittest discover -s tests -vGitHub Actions also validates addresses.json and compiles every tracked, non-archived Python module.
- Memory structures from OpenSauce (
Networking/Statistics.hpp) - Research informed by HaloCaster and Yelo Carnage