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

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

Guide Description
Getting Started Game API, coordinates, turn structure
Bot Approaches 6 approaches with full code
API Reference All function signatures
Training Guide Self-play, SFT, curriculum, distributed
Configuration Every tunable parameter
Dashboard REST API, WebSocket
Train Dashboard Web UI for training
SFT Guide Train from game collections
Advanced Solver, opening book, ensemble, MCTS tricks
Orca Bot Architectures, loading, training

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.1.4.tar.gz (227.8 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.1.4-cp313-cp313-win_amd64.whl (168.9 kB view details)

Uploaded CPython 3.13Windows x86-64

hexbot-4.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (260.3 kB view details)

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

hexbot-4.1.4-cp313-cp313-macosx_11_0_arm64.whl (193.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

hexbot-4.1.4-cp312-cp312-win_amd64.whl (168.9 kB view details)

Uploaded CPython 3.12Windows x86-64

hexbot-4.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (260.3 kB view details)

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

hexbot-4.1.4-cp312-cp312-macosx_11_0_arm64.whl (193.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

hexbot-4.1.4-cp311-cp311-win_amd64.whl (168.9 kB view details)

Uploaded CPython 3.11Windows x86-64

hexbot-4.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (260.3 kB view details)

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

hexbot-4.1.4-cp311-cp311-macosx_11_0_arm64.whl (193.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

hexbot-4.1.4-cp310-cp310-win_amd64.whl (168.9 kB view details)

Uploaded CPython 3.10Windows x86-64

hexbot-4.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (260.3 kB view details)

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

hexbot-4.1.4-cp310-cp310-macosx_11_0_arm64.whl (193.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

hexbot-4.1.4-cp39-cp39-win_amd64.whl (168.9 kB view details)

Uploaded CPython 3.9Windows x86-64

hexbot-4.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (260.3 kB view details)

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

hexbot-4.1.4-cp39-cp39-macosx_11_0_arm64.whl (193.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hexbot-4.1.4.tar.gz
Algorithm Hash digest
SHA256 d9663589c5449269823e1cae0828d1556be86497ad306e082e7f263533e5360a
MD5 75eb906c59a2d5c4aa5a810b06a431dc
BLAKE2b-256 3c41a9613314d1ea1670b165cc085ee2334bf91b3e234f619a39488dd2a27292

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexbot-4.1.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 168.9 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.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c8bb3967b5031c34c635d1114f3587f33bc004e56efff9ad331d64f2d3b60afe
MD5 605bbb75eb0bd4f0cf0171b1933ccae9
BLAKE2b-256 ce531e840d8fc7c726f02f16372cdbc2e0af803497225d64c78227da253101ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0f5f560c621c75a542122bd920569819aa3ecd2c590cf9e52d3643414602c619
MD5 96541e7324cec5dacaf8fd7dd2d9c0bd
BLAKE2b-256 905b78dfea7780cc10720c90f7051cb67d0251eb61bde683a95b37731b76e8a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52b20d6b40a2d909593b36a432aa96c376055265440b334d44e8a605ae6ae87b
MD5 9c1d6ab7df68c49b31f45d52c9730662
BLAKE2b-256 5d2968b93ee9354d52d8968d21447777e98dde49d8d0b54746153bbba76ab8fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexbot-4.1.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 168.9 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.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7ef9bc9d1439aa54ba55fe7103c70fd23f785ffc9889a0ffa7bf89031b0dff8e
MD5 d17c4aeda5e9e8a9f1b96fee6075cbb4
BLAKE2b-256 3c246179d3bbfda3bbb40e5ffcb4afe15394ab2b03970e5fe1299a2e7775c1ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a516a828cbe51cab5bc04bb66e8fe9edceb6c7ffa7f264cc50d8d8fa835e7c74
MD5 ee3c4ca8696c19171db5d0a3d3c22c28
BLAKE2b-256 8df10c401be5dad03624b6c24337fdc8d18ab90a153669cfa20964a3486b4b8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d609b45208ed69ef9120157e72b41105f88c6bba1de3aa3db3b963679aca337b
MD5 17f32a5439065abe89e649925fabb005
BLAKE2b-256 2fb0a671e6917fc943a8067df8ca0f93445074c6cd9fb4c17db54af40c18421f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexbot-4.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 168.9 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.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 270fa922ea7af641e7c8660511c6ce84f06806edb001449888c184f1f904bdc2
MD5 ad8a3f83ee5619b12017674935738513
BLAKE2b-256 1947f4fb01a7f382ae3b1e25165e24683c5e362d445e3219fa84b63f7fdedd32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c1fbf32a1b1d9e81732898376e43fa5927472ea8613ca37bdffe82cb97f17d6c
MD5 a6fac41c0fb76ec44af89c1438527cf2
BLAKE2b-256 fefe2f4df7edbc3354cc1908abc157ee815b90a73df63f7d3fbd74720c4f5826

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ffbd423f6aab3698659003c8d06b08ec0fd427ef83b43c8d06f302dbfb82d00
MD5 2ea915c9e28d7a3dd807dbb97c87f8d3
BLAKE2b-256 07117eb90212ead6f8b83194afc6315b9e9c2ede838cad7dde58978d98b1f1ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexbot-4.1.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 168.9 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.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 28b1188d7a216eacb647c0d43a56e9895508d2701b697d3113eb485f2e34435c
MD5 c41ab0a414f07bcb8e5354392be50729
BLAKE2b-256 7bd33afb83a98b7ff957caf2976a26028718744853a5d6303c9562e9eb8f1e06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85c6e6d1873d6c02d57e52f99af0ceadea263ef1766cbdf9ef89356e9715b0b4
MD5 ec4fa84b313974f0c5deb2d4f57ca3be
BLAKE2b-256 7dd307821f96390350955841ebcd910321f43a28ddeabdd761c9ddc431c1c7f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e704de982c7cc6e4efe7b31e5c85f1ff6bd4f9c518f0f44f370bef5458f8f28
MD5 0e6aa13d725f79e728898310c117b2e5
BLAKE2b-256 38e137b69a4a9ad5c60d29b4cb099bca2cfe5a00d1b6d7a1ce980da303ef907f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexbot-4.1.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 168.9 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.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 35f60d5664b0a80730d415fa7077c481481248ece6a82e15940b544163da287c
MD5 ac5502b2f641fdd72b9443c8ab22a384
BLAKE2b-256 6b93b478e393516971592b15e87303662b4153a326405c320dbff356ae08cc87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ce94fa97d06afd3aa05d005769d12eaaf611d735ce18dc84b12c09d8755ddd8
MD5 12d3925b8b5d210ed0dc3a21ed7d8cf4
BLAKE2b-256 60725ff10ca8a68fedf56595d7807f0e0dd0488c5b299976f5be2ac8d4c7ec70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hexbot-4.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 453cebb169279624b1a8f7f8362e3688a0ce3b1a29d86612d8654f14d9ef7792
MD5 91cb66897671925d72c4c36533fa1428
BLAKE2b-256 421b6daeb9cb222b958bb3915ffbc0f7e0064dfed0ea1c7b46757416da9a9e6e

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