CLI & Scripting
Practical patterns for automating Dealbreaker from the shell or driving it from another language over stdio.
Machine-Readable Output (--json)
Add --json to solve, best, replay, or bench to get clean JSON on stdout:
dealbreaker solve freecell --ms 1 --jsonSave a deal to a file, inspect it, or pass a custom position back in:
dealbreaker deal klondike --seed 42 > pos.json
dealbreaker solve klondike --state pos.json --jsonReplay a Solution Step-by-Step
Feed the output of solve --json into replay to inspect every intermediate board state (add --legal to include every legal move at each step):
dealbreaker solve freecell --ms 1 --json > sol.json
dealbreaker replay freecell --ms 1 --steps sol.json --legal --jsonBenchmark a Range of Deals
bench runs in parallel across all CPU cores by default (use --jobs 1 for single-threaded timing):
# 100 Microsoft FreeCell deals
dealbreaker bench freecell --microsoft --seeds 1..100 --max-states 500000
# 200 Klondike deals with per-deal details
dealbreaker bench klondike --seeds 1..200 --verbose --jsonDrive Dealbreaker from Any Process (serve)
If you're solving many positions from a script or backend service, dealbreaker serve <GAME> compiles the game once and speaks newline-delimited JSON (JSONL) over stdin / stdout:
dealbreaker serve freecell <<'EOF'
{"id": 1, "cmd": "deal", "ms": 1}
{"id": 2, "cmd": "quit"}
EOFEvery request may include an optional "id" field that is echoed in the response. See the CLI Reference for all supported serve commands.
Run in Docker
Pre-built multi-arch (linux/amd64, linux/arm64) scratch images are published to GitHub Container Registry on every release:
docker run --rm ghcr.io/samdobson/dealbreaker solve freecell --ms 1Mount your working directory to pass custom rules or state JSON files:
docker run --rm -v "$PWD:/work" -w /work ghcr.io/samdobson/dealbreaker solve my-game.json --state pos.json --jsonPass -i to keep stdin open when driving dealbreaker serve:
docker run --rm -i ghcr.io/samdobson/dealbreaker serve freecell <<'EOF'
{"id": 1, "cmd": "deal", "ms": 1}
{"id": 2, "cmd": "quit"}
EOFTo build the image locally from source:
docker build -t dealbreaker .