A genetic-programming system that evolves Go-playing programs. Genomes are lists of custom VM instructions that are evaluated by playing games against an opponent engine, then bred across generations to improve their playing ability.
Each genome is a program for a custom stack-based virtual machine (GoVM). On every genmove GTP request, the VM runs for a fixed number of clock cycles and outputs a board move via its X and Y output registers. The VM reads board state through a set of circular-iterator "board info" registers that expose stone positions, liberties, and spaces.
Evolution proceeds as follows:
- Each genome in the current population is written to a temporary file and played as a GTP engine against an opponent (default:
gosumi_2013.jar) usinggogui-twogtpfor match orchestration. - Win/loss results and move counts are recorded as fitness metrics.
- After the whole population is evaluated,
Breeder.breed()selects survivors and produces a new generation via mutation and crossover. - The new generation is saved to
current_population.pyand the cycle repeats.
GoBreeder/
├── breed/ # Core evolutionary engine
│ ├── vm.py # GoVM — custom register/stack machine
│ ├── breeder.py # Population management and evolutionary operators
│ ├── mediator.py # Orchestrates Breeder ↔ GoEngine; GTP server mode
│ ├── go_engine.py # GTP client/server wrapper
│ ├── data_structures.py # GoGenome, CircularList
│ ├── board_info.py # Board-state query helpers
│ └── config.py # Per-deployment path configuration
└── gui/ # PySide6 desktop GUI
├── app.py # Entry point (gobreeder-gui)
├── main_window.py # Four-tab main window
├── models/ # Pydantic app-state models
├── panels/ # Tab panel widgets
├── widgets/ # Reusable widgets (BoardWidget, GenomeCodeView, …)
└── vm_debug/ # VM step-debugger backend (QThread)
| Mode | Command |
|---|---|
| Breeding run (evolve a population) | uv run python mediator.py -gtp_breed -genome_file current_population.py |
| Single-genome GTP engine | uv run python mediator.py -genome_file breeding_genome.py |
| Desktop GUI | uv run gobreeder-gui |
A full PySide6 desktop application manages the entire workflow without needing the command line.
| Tab | Function |
|---|---|
| Deployments | Create, configure, and delete deployment directories. Each deployment is an independent copy of the breed directory with its own population and config. |
| Breeding Runs | Start/stop breeding runs (QProcess-based), monitor per-generation progress, and tail the run log in real time. Multiple deployments can run concurrently. |
| VM Inspector | Load any genome, step through its execution instruction by instruction, and inspect all registers, memory, stack, and the live 9×9 board state. |
| Archive & Library | Browse per-run archives, select individual genomes, export them, and compose new population files to inject into any deployment. |
(No screenshot yet — run
uv run gobreeder-guito see the GUI.)
GoVM is a custom register-and-stack machine with:
- Output registers
X,Y— the move coordinates emitted eachgenmove. - Arithmetic registers
RES,CRY,SGN,LOG. - Working registers
X0–X7,Y0–Y7,GP0–GP7. - Board pointer
STN— a 3×3 cursor over the board. - Board info iterators (
bi_blacks,bi_whites,bi_spaces,bi_white_freedoms,bi_black_freedoms,bi_all_stones) — circular lists that expose stone coordinates to the program. - Memory — 640 × 1 024 addressable 8-byte integer slots.
- Stack — unbounded push/pop stack.
The SteppableGoVM subclass exposes a generator-based step() interface used by the GUI debugger.
- Python ≥ 3.10
- uv (package/env manager)
- Java (for
gosumi_2013.jaropponent) onPATH gogui-twogtpbinary (bundled ingogui-v1.6.0-bin/)ref_v0.1_exereferee (bundled inGoBreeder/breed/)
git clone https://github.com/<your-org>/GoBreeder.git
cd GoBreeder
uv syncTo include development dependencies (tests, linting):
uv sync --group devuv run gobreeder-gui# From a deployment directory that has current_population.py
uv run python GoBreeder/breed/mediator.py \
-gtp_breed \
-genome_file /path/to/deployment/current_population.pyOr use the helper script:
bash GoBreeder/scripts/breed_pop.sh /path/to/deployment# Run all tests
uv run pytest
# Linting / formatting check
uv run ruff check .
# Type checking
uv run mypy GoBreeder277 tests, ruff clean, mypy clean.
A deployment is a directory that mirrors GoBreeder/breed/ with:
- Its own
config.py(basepathset to the deployment path). - Its own
current_population.py(active population). - A
runlog.txtappended to by breeding runs. - Optionally a
histories/subtree for per-move game recording.
Deployments can be created and managed via the GUI's Deployments tab, or manually using GoBreeder/scripts/deploy_breeder_instance.sh.
| File | Purpose |
|---|---|
GoBreeder/breed/vm.py |
Core VM implementation |
GoBreeder/breed/breeder.py |
Genetic operators and population management |
GoBreeder/breed/mediator.py |
GTP server / breeding orchestrator |
GoBreeder/breed/go_engine.py |
GTP engine wrapper |
GoBreeder/breed/data_structures.py |
GoGenome, CircularList |
GoBreeder/gui/app.py |
GUI entry point |
GoBreeder/gui/models/app_state.py |
Application-level Pydantic state |
GoBreeder/gui/vm_debug/ |
Step-debugger thread and session model |
tests/ |
277 pytest tests |
See GoBreeder/extras/external_go_docs/License.txt for third-party component licences.