GameState¶
This module provides a game state that is a snapshot of the game at a given time. At each turn, the game creates a new instance of this class. It gives an overview of scores, locations, available cheese, who is currently crossing mud, etc. It also provides a few useful functions to determine who is currently leading, etc. This game state is then provided to players so that they can make decisions based on the current state of the game.
- class GameState.GameState[source]¶
A game state is a snapshot of the game at a given time. It gives an overview of scores, locations, available cheese, who is currently crossing mud, etc. It also provides a few useful functions to determine who is currently leading, etc. Objects of this class are created each turn, so manually changing the attributes will not allow you to cheat :)
- __init__()[source]¶
Initializes a new instance of the class.
This constructor defines some public attributes that are used to store the state of the game. You can access these attributes to get information about the game state.
- Accessible attributes are:
player_locations
: Dictionary of player names and their current locations.score_per_player
: Dictionary of player names and their current scores.muds
: Dictionary of players currently crossing mud, with their target cell and the number of turns left to reach it.teams
: Dictionary of team names and their members.cheese
: List of cheese locations.turn
: Current turn number (starting from 0).
- is_in_mud(name)[source]¶
Returns whether a player is currently crossing mud.
- Parameters:
name (
str
) – Name of the player.- Return type:
bool
- Returns:
True
if the player is currently crossing mud,False
otherwise.
- game_over()[source]¶
Checks if the game is over. The game is over when there is no more cheese or when no team can catch up anymore.
- Return type:
bool
- Returns:
True
if the game is over,False
otherwise.