haive.games.framework.base.utils¶
Utility functions for game agents.
This module provides utility functions for running and managing game agents, including game execution and state visualization.
Example
>>> agent = ChessAgent(config)
>>> run_game(agent) # Run a new game
>>> run_game(agent, initial_state=saved_state) # Continue from a saved state
- Typical usage:
Use run_game to execute a complete game with an agent
Provide optional initial state to continue from a specific point
Monitor game progress through visualization and status updates
Functions¶
|
Run a complete game with the given agent. |
Module Contents¶
- haive.games.framework.base.utils.run_game(agent, initial_state=None)[source]¶
Run a complete game with the given agent.
This function executes a game from start to finish using the provided agent. It handles game initialization, move execution, state visualization, and error reporting. The game can optionally start from a provided initial state.
- Parameters:
Example
>>> agent = ChessAgent(ChessConfig()) >>> # Start a new game >>> run_game(agent) >>> >>> # Continue from a saved state >>> run_game(agent, saved_state)
Note
The function will print game progress to the console
Game visualization depends on the agent’s visualize_state method
Game history will be saved using the agent’s save_state_history method