[docs]classGame:""" The main entry point for the Mastermind game. Args: number_of_colors (int): The number of colors in the game. number_of_dots (int): The number of dots in each combination. maximum_attempts (int): The maximum number of attempts allowed in the game. game_mode (str): The game mode, such as "HvH", "HvAI", "AIvH", or "AIvAI". """def__init__(self,number_of_colors,number_of_dots,maximum_attempts,game_mode):self._state=GameParameter(number_of_colors,number_of_dots,maximum_attempts,game_mode)self._board=self._state._boardself._player_logic=PlayerLogic(self._state)self._game_flow=GameFlow(self._state,self._player_logic)
[docs]defstart_game(self)->Optional[str]:""" Starts the game. Returns: Optional[str]: A command from the player, if any. """returnself._game_flow.start_game()
[docs]defresume_game(self)->Optional[str]:""" Resumes the game. Returns: Optional[str]: A command from the player, if any. """returnself._game_flow.resume_game()
def__len__(self)->int:""" Returns the number of attempts made in the game. """returnlen(self._board)@propertydefnumber_of_colors(self)->int:""" Returns the number of colors in the game. """returnself._state.number_of_colors@propertydefnumber_of_dots(self)->int:""" Returns the number of dots in each combination. """returnself._state.number_of_dots@propertydefmaximum_attempts(self)->int:""" Returns the maximum number of attempts allowed in the game. """returnself._state.MAXIMUM_ATTEMPTS@propertydefgame_mode(self)->str:""" Returns the game mode. """returnself._state.GAME_MODE