Skip to main content

Python framework for building AI bots for Hexagonal Connect-6

Project description

hexbot

A Python framework for building AI bots for Hexagonal Tic-Tac-Toe (Connect-6 on an infinite hex grid). Fast C game engine, multiple neural network architectures, AlphaZero training pipeline, and a live training dashboard.

Home of the Orca bot.

PyPI Wiki

Full guides, learning path, and feature reference live on the Wiki. Start with Quickstart or Concepts. Try it now in Colab (free T4 GPU, ~5 minutes).

Built a great bot with this? Open an issue or get in touch, and I'll feature it here.

Model Zoo

Share bots with the community. Download by name, upload your trained checkpoints. Built-in metadata (architecture, ELO, author, description) keeps everything interoperable.

from orca.zoo import Zoo

# See what others have shared
Zoo.list()

# Try someone else's bot
bot = Zoo.download('orca-v3')

# Share yours
Zoo.package('hex_checkpoint_500.pt',
            name='my-bot-v1', author='You', elo=1450,
            description='Trained 500 iterations with hex-masked')
Zoo.upload('my-bot-v1.pt', name='my-bot-v1')

Trained something interesting? Publish it and the next person can pull it with one line. See the Evaluation and Sharing wiki page for the full lifecycle (Arena, Leaderboard, Zoo).

Featured Community Bots

No community bots rated yet. Train one, then Leaderboard().rate(bot, name='my-bot-v1') to land here. See Evaluation and Sharing.

This table is regenerated from leaderboard.json by scripts/update_featured_bots.py (runs in CI on every push to main).

Installation

pip install hexbot

Or from source (for development):

git clone https://github.com/Saiki77/hexbot-building-framework.git
cd hexbot-building-framework
pip install -e .               # core (game engine + torch)
pip install -e '.[dashboard]'  # + dashboard UI
pip install -e '.[all]'        # everything

The C engine auto-compiles on first import (cc/gcc/clang required).

Quick Start

from hexbot import HexGame, Bot, Arena

game = HexGame()
game.place(0, 0)         # P0: 1 stone first turn
game.place(1, 0)         # P1: first of 2
game.place(1, -1)        # P1: second stone

# Any function is a bot
def my_bot(game):
    return game.legal_moves()[0]

result = Arena(my_bot, Bot.heuristic(), num_games=20).play()

Orca Bot

Pre-trained AlphaZero-style bot. The included checkpoint is early-stage (65 iterations) - gets significantly stronger with more training.

from hexbot import Bot
orca = Bot.orca()
move = orca.best_move(game)

Train

# From game collections (fast bootstrap)
python -m orca.scrape --games 5000 --output games.jsonl
python -m orca.sft --data games.jsonl --then-selfplay 50

# Pure self-play
python -m orca.train --iterations 100

# With web dashboard
python train_dashboard.py

Network Architectures

Config Params Description
fast 656K Quick experiments
standard 3.9M Default Orca (128 filters, 12 ResBlocks)
hex-masked 3.9M Hex-neighbor masked CNN (recommended for hex)
large 14.5M Maximum strength (256 filters)
orca-transformer 4.4M CNN + transformer attention
hex-gnn 432K Graph neural network on hex topology
multiscale 1.1M Local CNN + global attention two-tower
python -m orca.train --config hex-gnn --iterations 50

Features

Feature Description
SFT Pipeline Train from game collections (JSONL/CSV/text), chain with self-play
Endgame Solver Deep alpha-beta with transposition cache, integrates with MCTS
Opening Book Trie-based lookup from winning games, blends with MCTS policy
6 Architectures CNN, transformer, GNN, multiscale, hybrid, fast
Mixed Precision FP16 on CUDA for 2x training speed
Distributed Multi-GPU (DDP) and multi-machine (Ray)
Skill Curriculum 6-level auto-progression: basics through endgame
Ensemble Average N checkpoints with uncertainty estimation
Model Zoo Share and download community models
Leaderboard Rate bots against references, compare head-to-head
Plugin System Register custom bots and network architectures
Dashboard REST + WebSocket API, live game replay, charts
30+ API Functions NN eval, MCTS search, threats, solver, augmentation

Bot Approaches

# Approach Complexity
1 Hand-tuned evaluation Low
2 Evolutionary weights Low
3 Minimax with alpha-beta Medium
4 Monte Carlo playouts Medium
5 Neural network (AlphaZero) High
6 Hybrid strategies High

Architecture

hexbot.py              Framework API (Bot, Arena, 30+ analysis functions)
hexgame.py             Game engine (wraps C engine via ctypes)
engine.c               2,300 lines optimized C (bitboard win detection)
bot.py                 Neural networks, MCTS, training pipeline
dashboard.py           Dashboard API (REST + WebSocket)
train_dashboard.py     Training dashboard with web UI
pyproject.toml         pip install config
orca/
  __init__.py          Orca bot loader
  config.py            All tunable parameters
  train.py             Training pipeline (CLI + library)
  sft.py               Supervised fine-tuning from games
  scrape.py            Game downloader
  solver.py            Endgame solver
  openings.py          Opening book
  curriculum.py        Skill-based curriculum
  ensemble.py          Multi-checkpoint ensemble
  distributed.py       Multi-GPU / Ray training
  zoo.py               Model zoo
  leaderboard.py       Bot rating system
  transformer_net.py   Transformer architecture
  hex_gnn.py           Graph neural network
  multiscale_net.py    Multi-scale architecture
  benchmark.py         Platform benchmark (compare Mac/CUDA/CPU)
  checkpoint.pt        Pre-trained weights
docs/                  Detailed documentation
examples/              Example bot scripts

Benchmark

Compare performance across platforms:

python -m orca.benchmark --quick    # ~30 seconds

Measures: C engine speed, NN inference, MCTS search, self-play, training steps, augmentation.

Device Support

Priority Device Platform
1 CUDA NVIDIA GPU (Linux/Windows)
2 MPS Apple Silicon (macOS)
3 CPU Any platform

Documentation

Full docs live on the Wiki (16 pages organized by Learn / Build / Train / Evaluate / Reference).

Good starting points:

Page What it covers
Quickstart 5 minutes from pip install to a bot playing
Game Rules Hex Connect-6 rules in 60 seconds
Concepts MCTS, AlphaZero, policy/value, ELO explained
Bot Approaches Six complete bot designs with full code
Training Guide Self-play, SFT, curriculum, distributed
Playing Online Run your bot on hexo.did.science
API Reference All public functions and classes
FAQ Common pitfalls and questions

Contributing

Built for the Hexagonal Tic-Tac-Toe community. Contributions welcome.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hexbot-4.2.1.tar.gz (256.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hexbot-4.2.1-cp313-cp313-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.13Windows x86-64

hexbot-4.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

hexbot-4.2.1-cp313-cp313-macosx_11_0_arm64.whl (220.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

hexbot-4.2.1-cp312-cp312-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.12Windows x86-64

hexbot-4.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

hexbot-4.2.1-cp312-cp312-macosx_11_0_arm64.whl (220.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

hexbot-4.2.1-cp311-cp311-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.11Windows x86-64

hexbot-4.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

hexbot-4.2.1-cp311-cp311-macosx_11_0_arm64.whl (220.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

hexbot-4.2.1-cp310-cp310-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.10Windows x86-64

hexbot-4.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

hexbot-4.2.1-cp310-cp310-macosx_11_0_arm64.whl (220.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

hexbot-4.2.1-cp39-cp39-win_amd64.whl (190.0 kB view details)

Uploaded CPython 3.9Windows x86-64

hexbot-4.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (299.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

hexbot-4.2.1-cp39-cp39-macosx_11_0_arm64.whl (220.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file hexbot-4.2.1.tar.gz.

File metadata

  • Download URL: hexbot-4.2.1.tar.gz
  • Upload date:
  • Size: 256.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1.tar.gz
Algorithm Hash digest
SHA256 66d108a194aa1699c3193f1f16f5500fdad2eae96d2f23f75f2e008b077a145e
MD5 917b3a430ea2fc1b0ec639a0ced22891
BLAKE2b-256 f49a7d4ebbdd238d7c12843b8cb6a844c094f062364317edc970045828640d41

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: hexbot-4.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1d1e0cf331aba6cb85d5cf80d8b30047ab2c8838615a1e5956b52c4aa5e514da
MD5 e9cf71209190aef4b039b530251471a1
BLAKE2b-256 ac6472a2f530aa829a0597c495376fb709e442a357b0e460021bec5c87c0b9ea

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9179a88898cc086a9c4e470a6dd51107cd98296de124f54cde04a74cce3d7ec
MD5 a4aeface8da6c20174c1030072dcead7
BLAKE2b-256 d25b1948de81a85dbf6cee4f89bf061584d866b3ab26f86bd608ad04fb655552

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c190aef0b433c1a46ebd1b5ee6dd7cee62ad8ebabf22e3af200cebbbecacb95
MD5 117a2a7570ec538ebc3df7b1eec18c19
BLAKE2b-256 84e4ab6e3639b67fbe09f81543a21280e6b47e39e655696aeec9053d10300719

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: hexbot-4.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 57d75fb23108e4d2d8d4a53455ded0d0d25b4989782c5156003c9f3377303fa7
MD5 fd4fcb5109aa771bb16ae7fa644fc0ea
BLAKE2b-256 c021fe80a6241894c72f136d7c5f2e87546230451c1c6ea9a8d2acbb36899ea0

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9347d760ff81158b4d81fdf3c6bf3e51f740ded7025e62c874386045a7231e23
MD5 1a5f1feb7fe93d86640f37554bc76240
BLAKE2b-256 a6b5422cedf3a0692fd8b22942c5a6fddb47b9b5f3fa8a54ab1ce692a417ceed

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1680ac00b1991e9652e27caeba0a1d51c1cc0709be21b80263c129fd44aed505
MD5 b69194077aab240ea16789dffe472c4c
BLAKE2b-256 89e12ae0ad6809fea4fefaf62a380ef01be8388565e93582d8d28048116f3612

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: hexbot-4.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ffa24ffb40418f540d171c8a89bf782a2a5047099c6ed07ede414e98228c63f1
MD5 c0d32d044ea61aa5d012d4d3bcb8524a
BLAKE2b-256 5a6b288d532184653f53b9f39c2084e1f60b74635d69b539fe114bda82a1dc00

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f4e74e5bfb6c11f8691146599ded5b0d2e2a219c1670df540b04e7989e2ee00f
MD5 23548ba3de1d6ccca47bae3cf1e283d6
BLAKE2b-256 3e6cabf81de5457a32ba694d7b2c271c3df54796414396a41ff7f14cafe4fc08

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c12427edf620f5a297bb0d77291f5f12fd0c241d284fc85b620676432bcf502
MD5 32675ffe9e37e64934cf862233f03422
BLAKE2b-256 b4267a9e5528876521df1674c8d15cde0c277fbe0963df5fbae4dd5b3b89f8cb

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: hexbot-4.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f0ba000349feb753b74796dcad420ccc3584793373f8bf37a3cfb46fd82c2984
MD5 5a62a2fb239313cb26863aad0455124a
BLAKE2b-256 91b3365b5264fe332574cc1c9f7c1da0c3ecaf2be2f436d4d5423bc46ccbe0b2

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 816874b3c4691dabfab0291ef2741c2ecc180a6af50ecfc66e15802fa27aa993
MD5 791cc71004c1c09cf88d4e1dd4f91585
BLAKE2b-256 81e577d5556b64f0174c66bc56ade83e69710afb63d9406b9b802898674ed6f0

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2380576a6b8778eb434b86eb5cc2a5f0250a2a41667a4318f7939afaf6e4e3f0
MD5 c68cb738e8d6952dafdbb83eb2e0d761
BLAKE2b-256 d4dc687764938da197ef15ae8b1f1fdb1b1265f6d9cd9c006e5c782a5efca82f

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: hexbot-4.2.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 190.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexbot-4.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0857d7d6114a6c6d005729ebbba4b9c3a7b7fcdc0da25300d57b4e540de5e6e8
MD5 b45e61bb8bfd1fe3d4c1a5bf3bfb3a89
BLAKE2b-256 519377b2b58def71676bef399805e6d8ac0058c80d48ee3945e9c4057025bcff

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3a135afd2bd79f6c3aba893eb66f531edabf14cc012973e6ad5ea3187e2f0cfe
MD5 15d5e5349fad57d7631e3463be2c61ec
BLAKE2b-256 a6759f7a51f78ee23a2bdc7bfefe05dcbe5cb2f7e2e2950fbfbdeeeaa48b0784

See more details on using hashes here.

File details

Details for the file hexbot-4.2.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hexbot-4.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5290089fa7bc9538cecf9c4bcef6bd7e607a60015ba0641a6dfed2ad9b0dd8e
MD5 61ded0f8dc6dc18ab42767d7f1db837c
BLAKE2b-256 1b4c6d6c44787e114a2af274430fa14a6889260bc22997e3ceae984c4cfdbd86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page