How darkmatter2222/connectx_gen2 works
Purpose and Entry Points
This is a Python ConnectX/Connect-N game-AI research and competition repository, centered on agents for the 8×7 connect-5 variant. Primary operational entry points are tournament runners (run_tournament.py, run_tournament_v3.py, run_tournament_ensemble.py), engine-level game execution (connectx/engine.py), and submission packaging (phase2/submissions/build.py).
Game Engine and Evaluation Boundary
connectx/engine.py is the core rules/execution boundary: bots should consume game state through its board/configuration conventions and return legal moves. Tournament orchestration runs agents against each other and records comparative outcomes:
• connectx/engine.py
• connectx/tournament.py
• run_tournament.py
This separates agent internals from match scheduling, scoring, and benchmark scripts.
Search-Agent Portfolio
The main production capability is a portfolio of interchangeable bot implementations. Alpha-beta/bitboard agents form the deterministic tactical-search family, including specialized 8×7×5 and opening-book variants:
• connectx/bots/bitboard_ab.py
• connectx/bots/bitboard_ab_8x7_5_v2_booked.py
• connectx/bots/bitboard_ab_ensemble.py
Monte Carlo variants provide alternate policy generation, including tactical, alpha-beta-assisted, and PUCT implementations:
• connectx/bots/mcts_8x7_5.py
• connectx/bots/mcts_8x7_5_ab.py
• connectx/bots/mcts_8x7_5_puct.py
Simple and behavioral-cloning bots provide baselines or learned-policy alternatives (connectx/bots/bc_bot.py, connectx/bots/random_bot.py).
Opening Knowledge and Hybrid Decision Flow
Opening books are serialized knowledge sources consulted by booked search agents before or alongside deeper search. The repository contains both general and variant-specific book implementations and JSON assets:
• connectx/bots/opening_book.py
• connectx/bots/opening_book_8x7_5_v2.py
• book_8x7_5_v2.json
Likely move-selection flow is: receive engine state → optional book lookup → tactical/search or MCTS evaluation → return selected column. Hybrid agents can combine book priors, alpha-beta evaluation, MCTS rollout/search, and neural value estimates.
Neural Value Pipeline
A value-network subsystem supports learned position evaluation and neural-assisted search. Model definitions/evaluators are under bots, while training and value-data generation are separately staged:
• connectx/bots/connectx_value_net.py
• connectx/bots/nn_evaluator.py
• connectx/training/value_generate.py
• connectx/training/value_train.py
Persisted checkpoints under models/ (for example models/value_net/best.pth) and self-play datasets under data/ are material runtime inputs. The .pth format and training layout indicate a PyTorch-based model workflow, though dependency declarations are not present in the tree.
Data Generation, Training, and Benchmark Feedback
Self-play and teacher/behavioral-cloning generation create datasets used by training stages; trained models can then feed neural evaluators or BC bots:
• connectx/training/selfplay_pipeline.py
• connectx/training/generate_teacher.py
• connectx/training/train_bc.py
Benchmark scripts compare variants, especially the 8×7×5 family, and produce result artifacts that guide agent selection:
• connectx/benchmarks/compare_8x7_5_v2_booked.py
• connectx/benchmarks/compare_mcts_variants.py
• connectx/benchmarks/mcts_comparison_results.json
Deployment and External Target
phase2/submissions/ is a packaging/validation boundary for competition delivery, with versioned manifests and submission state:
• phase2/submissions/build.py
• phase2/submissions/validate.py
• phase2/submissions/manifests/v0007.json
Kaggle is the apparent external competition target, supported by connectx/training/kaggle_self_contained.py and extensive Kaggle-focused research, rather than a web-service runtime.
Main entry points: tournament.py Tournament Scheduler · engine.py ConnectX Engine · mcts_8x7_5.py MCTS Variants · bitboard_ab_8x7_5_v2_booked.py Booked 8×7×5 Search
Components 18
Game & Evaluation
- ConnectX Engine · Defines game-state conventions and legal move execution.
connectx/engine.py - Tournament Scheduler · Schedules bot matchups and records comparative outcomes.
connectx/tournament.py - Tournament Runner
run_tournament.py
Agent Portfolio
- Bitboard Alpha-Beta · Deterministic tactical-search family.
connectx/bots/bitboard_ab.py - Booked 8×7×5 Search · Variant-specialized alpha-beta agent with opening knowledge.
connectx/bots/bitboard_ab_8x7_5_v2_booked.py - Search Ensemble
connectx/bots/bitboard_ab_ensemble.py - MCTS Variants · Includes tactical, alpha-beta-assisted, and PUCT policies.
connectx/bots/mcts_8x7_5.py - 8×7×5 Opening Book
book_8x7_5_v2.json - Value Network · Learned position-value model used by neural evaluation.
connectx/bots/connectx_value_net.py - Neural Evaluator
connectx/bots/nn_evaluator.py
Learning Pipeline
- Self-Play Generation
connectx/training/selfplay_pipeline.py - Value Data Generation
connectx/training/value_generate.py - Value Training
connectx/training/value_train.py - Value Checkpoint
models/value_net/best.pth - MCTS Benchmark · Compares search variants and produces selection feedback.
connectx/benchmarks/compare_mcts_variants.py
Competition Delivery
- Submission Builder
phase2/submissions/build.py - Submission Validator
phase2/submissions/validate.py - Kaggle Competition
Connections 21
- Tournament Runner → Tournament Scheduler: runs
- Tournament Scheduler → ConnectX Engine: executes matches through
- Tournament Scheduler → Bitboard Alpha-Beta: evaluates
- Tournament Scheduler → Booked 8×7×5 Search: evaluates
- Tournament Scheduler → MCTS Variants: evaluates
- ConnectX Engine → Bitboard Alpha-Beta: provides state to
- ConnectX Engine → Booked 8×7×5 Search: provides state to
- ConnectX Engine → MCTS Variants: provides state to
- 8×7×5 Opening Book → Booked 8×7×5 Search: opening lookup
- Bitboard Alpha-Beta → Search Ensemble: search component
- MCTS Variants → Search Ensemble: policy component
- Self-Play Generation → Value Data Generation: positions
- Value Data Generation → Value Training: value dataset
- Value Training → Value Checkpoint: writes
- Value Checkpoint → Neural Evaluator: loads
- Value Network → Neural Evaluator: defines model
- Neural Evaluator → Search Ensemble: value estimates
- MCTS Benchmark → MCTS Variants: compares
- MCTS Benchmark → Booked 8×7×5 Search: compares
- Submission Builder → Submission Validator: validates package
- Submission Validator → Kaggle Competition: delivers to