ahorn.GameBase package¶
Submodules¶
ahorn.GameBase.Action module¶
ahorn.GameBase.Actor module¶
-
class
ahorn.GameBase.Actor.
Actor
¶ Bases:
object
An actor performs actions and drives a game from state to state.
-
get_action
(state)¶ Return the action the actor wants to take in a given state.
- State:
- The state in which the actor must perform an action
- action: Action
- The action the actor wants to take in this state.
-
ahorn.GameBase.Player module¶
-
class
ahorn.GameBase.Player.
Player
¶ Bases:
ahorn.GameBase.Actor.Actor
A player is an actor that actively decides which action to take
ahorn.GameBase.State module¶
-
class
ahorn.GameBase.State.
State
(players)¶ Bases:
object
Describes the attributes of a game at a particular time
-
copy
(other)¶ Copy the content of another state into this state
Deep copy, i.e. modifying the copied state can not influence the content of the original state.
- other : State
- The state from which to copy the content
-
get_actor
()¶ Return the actor that must perform an action in this state.
- Actor
- The actor that must perform an action in this state.
-
get_legal_actions
(actor)¶ Return the legal actions a player can take in this state.
- actor: Actor
- the actor who wants to know which actions he can take
- actions: List
- a list of Actions
-
get_players
()¶ Return a list of all the players in the game.
- List<Player>
- A list of all the players in the game.
-
get_random
(player)¶ Get a random sample from the information set of the current state.
This method can be used to hide certain attributes of the state, such as opponent’s cards. In case of games with perfect information this information contains only the state itself, and a copy of the state itself is returned.
- player: Player
- The information set is created from the point of view of this actor
- State
- A random sample from the information set
-
get_utility
(player)¶ Return the utility a given player receives.
If the state is final, returns a utility, else returns None
- player: Player
- The player for which to find the utility
- utility: int
- The utility received by the player, or None
-
is_final
()¶ Return true if the state is final, i.e. the game is over
- bool
- True if the state is final, false otherwise
-
str
(player)¶ String representation of this state, from the eyes of a given player.
A string representation of the state, from the eyes of a given player. In games of incomplete information, this should hide the opponent cards, the deck, etc. In games of complete information, ignore the player.
The string representation should be hashable, i.e. all states with the same hash should be in the same information set.
- player: Player
- The player from who’s eyes the state should be represented
- str
- String representation of this state.
-