Interface Behaviour
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
AbstractBehaviour
,ChooseLastBehaviour
,FlatMonteCarloBehaviour
,GameStateValueBehaviour
,GreedyOptimizeTurn
,IntelligentBehaviour
,MonteCarloTreeSearchBehaviour
,PlayGameLogicRandomBehaviour
,PlayRandomBehaviour
,RequestActionFunction
,UtilityBehaviour
Behaviours specify a delegate for player action and mulligan requests.
Behaviours live inside Player
objects, and they're used by the GameContext
to determine what action
or mulligan a player chose to do. In this model, the game context is responsible for calling the methods in this
class. The GameLogic
typically executes as many game rules as possible until it reaches the next point where
an action is requested. The GameContext
is then responsible for getting the next action.
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clones the behaviour, typically with its internal state.getName()
Gets a name for the behaviour.default boolean
isHuman()
Determines whether this behaviour's actions were determined by a human.mulligan
(GameContext context, Player player, List<Card> cards) Use the provided context, player and first hand cards to determine which cards to discard during a mulligan phase.default void
mulliganAsync
(GameContext context, Player player, List<Card> cards, Consumer<List<Card>> handler) Asynchronously request a mulligan.void
onGameOver
(GameContext context, int playerId, int winningPlayerId) Notify the behaviour that the game is over, allowing it to clean up any state.requestAction
(GameContext context, Player player, List<GameAction> validActions) Requests an action from the player.default void
requestActionAsync
(GameContext context, Player player, List<GameAction> validActions, Consumer<GameAction> callback) Requests an action from a player asynchronously.
-
Method Details
-
clone
Behaviour clone()Clones the behaviour, typically with its internal state.- Returns:
- A clone of the
Behaviour
instance.
-
getName
String getName()Gets a name for the behaviour. This should correspond to how the decisions are being made, e.g., a"Human Behaviour"
or an"AI Behaviour
.- Returns:
- A
String
description of the behaviour.
-
mulligan
Use the provided context, player and first hand cards to determine which cards to discard during a mulligan phase.- Parameters:
context
- The game context.player
- The player who's mulliganing.cards
- The cards in the player's first hand.- Returns:
- The cards the player chose to discard.
-
onGameOver
Notify the behaviour that the game is over, allowing it to clean up any state.- Parameters:
context
- The context of the game that has ended.playerId
- The player that corresponds to this behaviour.winningPlayerId
- The winning player.
-
requestAction
Requests an action from the player.- Parameters:
context
- The game context where the choice is being made.player
- The player who is making the choice.validActions
- The valid actions the player has to choose from.- Returns:
- One of the
validActions
that correspond to the player's choice.
-
mulliganAsync
default void mulliganAsync(GameContext context, Player player, List<Card> cards, Consumer<List<Card>> handler) Asynchronously request a mulligan.- Parameters:
context
- The game context.player
- The player who is mulliganing.cards
- The cards in the player's first hand.handler
- The callback when the player chose which cards to discard.- See Also:
-
requestActionAsync
default void requestActionAsync(GameContext context, Player player, List<GameAction> validActions, Consumer<GameAction> callback) Requests an action from a player asynchronously.- Parameters:
context
- The game context where the choice is being made.player
- The player who is making the choice.validActions
- The valid actions the player has to choose from.callback
- The callback whose argument is one of thevalidActions
that correspond to the player's
-
isHuman
default boolean isHuman()Determines whether this behaviour's actions were determined by a human.- Returns:
true
if the actions are determined by a human,false
otherwise.
-