haive.games.nim.standalone_game =============================== .. py:module:: haive.games.nim.standalone_game .. autoapi-nested-parse:: Standalone game implementation of Nim. This script allows playing Nim without requiring the full Haive framework. Classes ------- .. autoapisummary:: haive.games.nim.standalone_game.NimGameManager haive.games.nim.standalone_game.NimMove haive.games.nim.standalone_game.NimState haive.games.nim.standalone_game.NimUI Functions --------- .. autoapisummary:: haive.games.nim.standalone_game.main haive.games.nim.standalone_game.parse_args Module Contents --------------- .. py:class:: NimGameManager Manager for the Nim game. .. py:method:: apply_move(state, move) :staticmethod: Apply a move to the current state. .. py:method:: check_game_status(state) :staticmethod: Check and update the game status. .. py:method:: initialize(pile_sizes = None, misere_mode = False) :staticmethod: Initialize a new game state. .. py:class:: NimMove(/, **data) Bases: :py:obj:`pydantic.BaseModel` Move in the Nim game. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:class:: NimState(/, **data) Bases: :py:obj:`pydantic.BaseModel` State for the Nim game. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:property:: board_string :type: str Return a string representation of the board. .. py:property:: is_game_over :type: bool Check if the game is over. .. py:property:: nim_sum :type: int Calculate the nim-sum (XOR sum) of the pile sizes. .. py:property:: stones_left :type: int Return the total number of stones left. .. py:class:: NimUI(delay = 0.5) UI for the Nim game. Initialize the UI. .. py:method:: announce_winner(state) Announce the winner of the game. .. py:method:: display_game_state(state) Display the current game state. .. py:method:: get_computer_move(state) Generate a computer move. .. py:method:: prompt_for_move(state) Prompt the user for a move. .. py:function:: main() Run the Nim game. .. py:function:: parse_args() Parse command line arguments.