"""LangGraph Platform graph entry points for haive-games.This module exposes all game agent graphs as callable factories forLangGraph Platform (langgraph.json). Each function returns a compiledLangGraph StateGraph served via ``langgraph dev`` or LangGraph Cloud.All 22 games listed here can be instantiated with default configuration."""importloggingfromdotenvimportload_dotenvload_dotenv()logger=logging.getLogger(__name__)# ---------------------------------------------------------------------------# Helpers# ---------------------------------------------------------------------------def_game(agent_cls,config_cls,**config_kwargs):"""Create a game agent with analysis/visualization disabled."""defaults={"enable_analysis":False,"visualize":False}defaults.update(config_kwargs)try:config=config_cls(**defaults)exceptException:# Some configs don't accept all kwargsconfig=config_cls()returnagent_cls(config).app# ---------------------------------------------------------------------------# Standard Two-Player Board Games# ---------------------------------------------------------------------------
[docs]deftic_tac_toe():"""Tic-Tac-Toe: AI vs AI on a 3x3 grid."""fromhaive.games.tic_tac_toe.agentimportTicTacToeAgentfromhaive.games.tic_tac_toe.configimportTicTacToeConfigreturn_game(TicTacToeAgent,TicTacToeConfig)
[docs]defchess():"""Chess: AI vs AI standard chess."""fromhaive.games.chess.agentimportChessAgentfromhaive.games.chess.configimportChessConfigreturn_game(ChessAgent,ChessConfig)
[docs]defconnect4():"""Connect4: AI vs AI four-in-a-row."""fromhaive.games.connect4.agentimportConnect4Agentfromhaive.games.connect4.configimportConnect4AgentConfigreturn_game(Connect4Agent,Connect4AgentConfig)
[docs]defcheckers():"""Checkers: AI vs AI draughts."""fromhaive.games.checkers.agentimportCheckersAgentfromhaive.games.checkers.configimportCheckersAgentConfigreturn_game(CheckersAgent,CheckersAgentConfig)
[docs]defnim():"""Nim: AI vs AI mathematical strategy game."""fromhaive.games.nim.agentimportNimAgentfromhaive.games.nim.configimportNimConfigreturn_game(NimAgent,NimConfig)
[docs]defbattleship():"""Battleship: AI vs AI naval strategy."""fromhaive.games.battleship.agentimportBattleshipAgentfromhaive.games.battleship.configimportBattleshipAgentConfigreturn_game(BattleshipAgent,BattleshipAgentConfig)
[docs]defgo():"""Go: AI vs AI on a Go board."""fromhaive.games.go.agentimportGoAgentfromhaive.games.go.configimportGoAgentConfigreturn_game(GoAgent,GoAgentConfig)
[docs]defreversi():"""Reversi/Othello: AI vs AI disc-flipping strategy."""fromhaive.games.reversi.agentimportReversiAgentfromhaive.games.reversi.configimportReversiConfigreturn_game(ReversiAgent,ReversiConfig)
[docs]defmancala():"""Mancala: AI vs AI seed-sowing board game."""fromhaive.games.mancala.agentimportMancalaAgentfromhaive.games.mancala.configimportMancalaConfigreturn_game(MancalaAgent,MancalaConfig)
[docs]defmastermind():"""Mastermind: AI code-breaking logic game."""fromhaive.games.mastermind.agentimportMastermindAgentfromhaive.games.mastermind.configimportMastermindConfigreturn_game(MastermindAgent,MastermindConfig)
[docs]defdominoes():"""Dominoes: AI vs AI tile-matching game."""fromhaive.games.dominoes.agentimportDominoesAgentfromhaive.games.dominoes.configimportDominoesAgentConfigreturn_game(DominoesAgent,DominoesAgentConfig)
[docs]deffox_and_geese():"""Fox and Geese: AI vs AI asymmetric hunt game."""fromhaive.games.fox_and_geese.agentimportFoxAndGeeseAgentfromhaive.games.fox_and_geese.configimportFoxAndGeeseConfigreturn_game(FoxAndGeeseAgent,FoxAndGeeseConfig)
[docs]defmafia():"""Mafia: Multi-agent social deduction game."""fromhaive.games.mafia.agentimportMafiaAgentfromhaive.games.mafia.configimportMafiaAgentConfigreturn_game(MafiaAgent,MafiaAgentConfig)
[docs]defrisk():"""Risk: Multi-agent world domination strategy. Note: Risk uses a standalone Pydantic model, not a LangGraph agent. Requires custom instantiation. """fromhaive.games.risk.agentimportRiskAgenta=RiskAgent(name="risk")# Risk doesn't use LangGraph compilation - return its internal graphifhasattr(a,"app")anda.app:returna.appraiseNotImplementedError("Risk agent does not produce a LangGraph graph")
[docs]defpoker():"""Poker: Multi-agent card game. Note: Poker requires engine configurations for each player. """fromhaive.games.poker.agentimportPokerAgentfromhaive.games.poker.configimportPokerAgentConfigconfig=PokerAgentConfig()agent=PokerAgent(config)returnagent.app
[docs]defholdem():"""Texas Hold'em: Multi-agent poker variant."""fromhaive.games.hold_em.game_agentimportHoldemGameAgentfromhaive.games.hold_em.configimportHoldemGameAgentConfigreturn_game(HoldemGameAgent,HoldemGameAgentConfig)
[docs]defblackjack():"""Blackjack: Card game against the dealer."""fromhaive.games.cards.standard.blackjack.agentimportBlackjackAgentfromhaive.games.cards.standard.blackjack.configimportBlackjackAgentConfigreturn_game(BlackjackAgent,BlackjackAgentConfig)
[docs]defwordle():"""Word Connections: Single-player word puzzle."""fromhaive.games.single_player.wordle.agentimportWordConnectionsAgentfromhaive.games.single_player.wordle.configimportWordConnectionsAgentConfigreturn_game(WordConnectionsAgent,WordConnectionsAgentConfig)