Skip to main content

haive-games for Haive framework

Project description

haive-games

LLM-powered games for agent evaluation, learning, and fun.
A curated suite of game environments + AI agents built on the Haive framework.

Python License Haive Rich LangGraph


๐Ÿšง Status: Under Active Development

haive-games is currently being migrated to the latest Haive framework APIs.
Expect breaking changes while the package converges on the unified Haive runtime + agent protocol standards.

  • โœ… Core games and agents are usable today
  • ๐Ÿ”„ APIs, configs, and imports may change during migration
  • ๐Ÿงช Test coverage is expanding (no-mocks, real integration focus)

๐ŸŽฏ Overview

Haive Games is a comprehensive collection of LLM-powered game agents and game environments designed for:

  • Agent evaluation in structured, rule-based settings
  • Strategy + reasoning demonstrations (planning, deduction, imperfect information)
  • Multi-agent coordination experiments (teams, tournaments, meta-controllers)
  • Developer examples of Haive patterns (state machines, tool use, graph workflows)

Highlights

  • โœ… 22+ complete games with consistent APIs
  • ๐Ÿค– LLM-powered players with configurable personalities and difficulty
  • ๐ŸŽ›๏ธ Rich terminal UI with state visualization
  • ๐ŸŸ๏ธ Tournament mode for benchmarking and comparisons
  • ๐Ÿ“Š Metrics + telemetry hooks (timing, turns, decisions)

Project link: https://tinyurl.com/haive-games


๐Ÿ“ฆ Installation

From PyPI

pip install haive-games

With Poetry

poetry add haive-games

From source (monorepo)

cd haive/packages/haive-games
pip install -e .

๐Ÿš€ Quick Start

Below is a minimal example showing how to run two games with LLM-driven agents.

from haive.games.chess import ChessAgent, ChessConfig
from haive.games.checkers import CheckersAgent, CheckersAgentConfig
from haive.core.models.llm.configs import LLMConfig

# 1) Configure LLMs for players
llm_config = LLMConfig(
    model="gpt-4",
    temperature=0.7,
    max_tokens=1000,
)

# 2) Chess
chess_config = ChessConfig(
    aug_llm_configs={
        "white_player": llm_config,
        "black_player": llm_config,
    }
)

chess_agent = ChessAgent(chess_config)
chess_result = chess_agent.run_game(visualize=True)

# 3) Checkers
checkers_config = CheckersAgentConfig(
    aug_llm_configs={
        "player1": llm_config,
        "player2": llm_config,
    }
)

checkers_agent = CheckersAgent(checkers_config)
checkers_result = checkers_agent.run_game(visualize=True)

print(f"Chess winner: {chess_result.get('winner')}")
print(f"Checkers winner: {checkers_result.get('winner')}")

๐Ÿ—‚๏ธ Game Catalog

haive-games includes a wide variety of games across multiple difficulty levels and reasoning types.

๐Ÿ† Classic Board Games

  • Chess โ€” FEN support, strategic analysis, configurable personalities
  • Checkers โ€” mandatory jumps, king promotion, rich UI
  • Go โ€” territory control and capture mechanics
  • Reversi (Othello) โ€” flipping mechanics + positional play
  • Clue โ€” mystery deduction and hypothesis tracking

๐ŸŽฏ Strategy Games

  • Tic-Tac-Toe โ€” position evaluation + forced wins
  • Connect 4 โ€” gravity-based tactics and win detection
  • Battleship โ€” hidden placement, targeting, information gathering
  • Risk โ€” territorial control + dice combat
  • Mancala โ€” sowing/capture mechanics

๐Ÿƒ Card Games

  • Poker โ€” Texas Holdโ€™em + bluffing + hand evaluation
  • Texas Holdโ€™em (advanced) โ€” tournaments + deeper betting model
  • Blackjack โ€” probabilistic play + strategy variants

๐ŸŽญ Social Deduction

  • Among Us โ€” tasks, deception, voting mechanics
  • Mafia / Werewolf โ€” role-based day/night play

๐Ÿงฉ Puzzle & Logic

  • Mastermind โ€” code-breaking via deduction
  • Nim โ€” mathematical optimal play
  • Fox and Geese โ€” asymmetric strategy

๐Ÿข Economic

  • Monopoly โ€” trading + development + risk management

๐ŸŽจ Other

  • Dominoes โ€” tile-matching variants
  • Debate โ€” structured argumentation + scoring/judging

๐Ÿง  How the Games Are Built

Each game follows a consistent architecture designed for reuse and extensibility:

Game Agent (e.g., ChessAgent)
โ”œโ”€โ”€ Configuration (GameConfig)
โ”œโ”€โ”€ State Management (GameState, reducers, history)
โ”œโ”€โ”€ Player Engines (LLM configs / providers)
โ”œโ”€โ”€ Rules + Validation (legal actions, win conditions)
โ”œโ”€โ”€ UI Layer (Rich rendering, progress, panels)
โ””โ”€โ”€ Workflow (graph-based game loop / stages)

Core Components

  1. Agent Controller
    Orchestrates the game loop and delegates decisions to players.

  2. State System
    Tracks turns, legal moves, history, and derived information.

  3. Player Engines
    Configurable LLM-backed players (temperature, prompts, tool access).

  4. UI/Visualization
    Rich terminal UI for live play and debugging.


๐ŸŸ๏ธ Tournament Mode

Run multiple games repeatedly to compare agents, prompts, or models.

from haive.games.tournament import Tournament

tournament = Tournament([
    (ChessAgent, chess_config),
    (CheckersAgent, checkers_config),
    # (ClueAgent, clue_config),
])

results = tournament.run(rounds=10)

print(f"Tournament winner: {results.winner}")
print(f"Leaderboard:\n{results.leaderboard}")

๐ŸŽญ AI Personalities & Difficulty

Tune player behavior by adjusting LLM configuration:

from haive.core.models.llm.configs import LLMConfig

aggressive = LLMConfig(
    model="gpt-4",
    temperature=0.9,
    system_prompt="Play aggressively. Take calculated risks and pressure opponents."
)

defensive = LLMConfig(
    model="gpt-4",
    temperature=0.3,
    system_prompt="Play defensively. Avoid losing positions and prioritize safety."
)

analyzer = LLMConfig(
    model="gpt-4",
    temperature=0.1,
    system_prompt="Be objective. Evaluate positions carefully and explain key ideas."
)

๐Ÿ“Š Metrics & Monitoring

Many games can collect timing and decision metadata:

config = ChessConfig(
    aug_llm_configs=llm_configs,
    enable_analysis=True,
    log_level="DEBUG",
    collect_metrics=True,
)

agent = ChessAgent(config)
result = agent.run_game()

metrics = result.get("metrics", {})
print("avg_move_time:", metrics.get("avg_move_time"))
print("analysis_calls:", metrics.get("analysis_calls"))

๐Ÿงช Testing

haive-games follows a production-style testing approach, favoring real components whenever possible.

# Run all tests
poetry run pytest packages/haive-games/tests/ -v

# Run a specific game test suite
poetry run pytest packages/haive-games/tests/test_chess/ -v

Lint / format:

poetry run ruff check packages/haive-games/src/
poetry run black packages/haive-games/src/

๐Ÿ“ Package Structure

haive-games/
โ”œโ”€โ”€ src/haive/games/           # Game implementations
โ”‚   โ”œโ”€โ”€ chess/
โ”‚   โ”œโ”€โ”€ checkers/
โ”‚   โ”œโ”€โ”€ go/
โ”‚   โ”œโ”€โ”€ among_us/
โ”‚   โ”œโ”€โ”€ mafia/
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ examples/                  # Demo scripts and usage patterns
โ”œโ”€โ”€ tests/                     # Game + integration tests
โ””โ”€โ”€ project_docs/              # Guides, architecture notes, and references

๐Ÿงฉ Adding a New Game

  1. Create a game directory: src/haive/games/your_game/

  2. Implement the required components:

    • agent.py โ€” main controller
    • config.py โ€” configuration models
    • state.py โ€” state + reducers + transitions
    • models.py โ€” structured models used by state/actions
    • README.md โ€” game docs + examples
  3. Add tests: tests/test_your_game/

  4. Register it in the package index (if applicable)


๐Ÿ—บ๏ธ Roadmap

  • ๐ŸŽ›๏ธ Unified agent config for all games
  • ๐Ÿง  Better evaluation harness + standardized metrics output
  • ๐ŸŸ๏ธ Multi-league tournaments (ELO / TrueSkill)
  • ๐Ÿ–ฅ๏ธ Optional web UI for select games
  • ๐Ÿ”Œ Tight integration with Haive MCP + tool ecosystems

๐Ÿค Contributing

Contributions are welcome:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for changes
  4. Ensure formatting + lint passes
  5. Open a PR

๐Ÿ“„ License

MIT License โ€” see LICENSE.


๐Ÿ”— Support

  • Issues: open a GitHub issue on the Haive monorepo (or relevant package repo)
  • Docs: see the Haive documentation hub

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

haive_games-1.0.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

haive_games-1.0.0-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file haive_games-1.0.0.tar.gz.

File metadata

  • Download URL: haive_games-1.0.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for haive_games-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4be318471da19e187479d0b513a9664b2fc3422aab831b4566db56fd40d32487
MD5 2f9c962c3ec886620906ee4a619a85a0
BLAKE2b-256 8e43549f2ccd495110e34236687ba8beb78ca184a85519ecfd3568d4185c0366

See more details on using hashes here.

File details

Details for the file haive_games-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: haive_games-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for haive_games-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad865fd5b66ef2692a485a495fee851323ace28b54ff7686478c9a9e244c6e29
MD5 a1960139917790fcf7e653b7992a59b1
BLAKE2b-256 2f229e8d1f065208142853297b7fa847dd80901c542cb7b2fec2085a41bde4fc

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