haive.games.framework.base.template_generator ============================================= .. py:module:: haive.games.framework.base.template_generator .. autoapi-nested-parse:: Template generator for game agents (EXPERIMENTAL). This experimental module provides a template generator for creating new game implementations. It automates the creation of boilerplate code and ensures consistency across different game implementations. .. warning:: This module is experimental and its API may change without notice. Use with caution in production environments. .. rubric:: Example >>> # Create templates for a new chess game >>> generator = GameTemplateGenerator( ... game_name="Chess", ... player1_name="white", ... player2_name="black", ... enable_analysis=True ... ) >>> generator.generate_templates() Typical usage: - Initialize the generator with game details - Generate all template files at once - Customize the generated code for your specific game Classes ------- .. autoapisummary:: haive.games.framework.base.template_generator.GameTemplateGenerator Module Contents --------------- .. py:class:: GameTemplateGenerator(game_name, player1_name = 'player1', player2_name = 'player2', enable_analysis = True) Experimental template generator for new board game implementations. This class automates the creation of boilerplate code for implementing new board games within the framework. It generates a complete set of files with proper structure, documentation, and type hints. .. warning:: This class is experimental and its API may change without notice. Generated code may need manual adjustments for specific games. .. attribute:: game_name The name of the game (used for class names). :type: str .. attribute:: player1_name Name for player 1. :type: str .. attribute:: player2_name Name for player 2. :type: str .. attribute:: enable_analysis Whether to include analysis in templates. :type: bool .. attribute:: game_slug Slugified version of the game name for file paths. :type: str .. attribute:: game_class_name CamelCase version of game name for class names. :type: str .. attribute:: base_dir Base directory for generated files. :type: str .. rubric:: Example >>> generator = GameTemplateGenerator("Tic Tac Toe") >>> generator.generate_templates() ✅ Generated template files for Tic Tac Toe in src/haive/agents/agent_games/tic_tac_toe Initialize the template generator. :param game_name: The name of the game (used for class names). :type game_name: str :param player1_name: Name for player 1. Defaults to "player1". :type player1_name: str, optional :param player2_name: Name for player 2. Defaults to "player2". :type player2_name: str, optional :param enable_analysis: Whether to include analysis in templates. Defaults to True. :type enable_analysis: bool, optional .. rubric:: Example >>> generator = GameTemplateGenerator( ... game_name="Chess", ... player1_name="white", ... player2_name="black" ... ) .. py:method:: generate_templates(output_dir = None) Generate all template files for the game. This method creates a complete set of files needed for a new game implementation, including models, state management, configuration, and example usage. :param output_dir: Optional directory to write files to. If not provided, uses the standard package structure. :type output_dir: str, optional .. rubric:: Example >>> generator = GameTemplateGenerator("Chess") >>> # Generate in default location >>> generator.generate_templates() >>> # Generate in custom location >>> generator.generate_templates("my_games/chess")