Package net.royalur.rules.simple
Class SimpleRuleSet
java.lang.Object
net.royalur.rules.RuleSet
net.royalur.rules.simple.SimpleRuleSet
The most common, simple, rules of the Royal Game of Ur.
This still allows a large range of custom rules.
-
Field Summary
Fields inherited from class net.royalur.rules.RuleSet
boardShape, diceFactory, paths, pieceProvider, playerStateProvider, sampleDice
-
Constructor Summary
ConstructorDescriptionSimpleRuleSet
(BoardShape boardShape, PathPair paths, DiceFactory diceFactory, PieceProvider pieceProvider, PlayerStateProvider playerStateProvider, boolean safeRosettes, boolean rosettesGrantExtraRolls, boolean capturesGrantExtraRolls) Instantiates a simple rule set for the Royal Game of Ur. -
Method Summary
Modifier and TypeMethodDescriptionapplyMove
(WaitingForMoveGameState state, long timeSinceGameStartMs, Move move) Appliesmove
tostate
to generate the new state of the game.applyRoll
(WaitingForRollGameState state, long timeSinceGameStartMs, Roll roll) Appliesroll
tostate
to generate the new state of the game.boolean
Gets whether rosettes are considered safe squares in this rule set.boolean
Gets whether capturing a piece grants an additional roll.boolean
Gets whether landing on rosette tiles grants an additional roll.findAvailableMoves
(Board board, PlayerState player, Roll roll) Finds all available moves from the given state.Generates the initial state for a game.selectLandmarkStates
(List<GameState> states) Selects only the states that are required to reproduce exactly what happened in a game using this rule set.boolean
shouldGrantExtraRoll
(MovedGameState movedState) Determines whether the move represented bymovedState
should grant another roll to the player that made the move.Methods inherited from class net.royalur.rules.RuleSet
applyAbandon, applyResign, createSimple, getBoardShape, getDiceFactory, getPaths, getPieceProvider, getPlayerStateProvider, getSampleDice, getSettings
-
Constructor Details
-
SimpleRuleSet
public SimpleRuleSet(BoardShape boardShape, PathPair paths, DiceFactory diceFactory, PieceProvider pieceProvider, PlayerStateProvider playerStateProvider, boolean safeRosettes, boolean rosettesGrantExtraRolls, boolean capturesGrantExtraRolls) Instantiates a simple rule set for the Royal Game of Ur.- Parameters:
boardShape
- The shape of the game board.paths
- The paths that the players must take around the board.diceFactory
- The generator of dice that are used to generate dice rolls.pieceProvider
- Provides the manipulation of piece values.playerStateProvider
- Provides the manipulation of player states.safeRosettes
- Whether rosette tiles are safe squares for pieces.rosettesGrantExtraRolls
- Whether landing on rosette tiles gives an extra roll.capturesGrantExtraRolls
- Whether capturing a piece gives an extra roll.
-
-
Method Details
-
createCompatibleFastGame
-
areRosettesSafe
public boolean areRosettesSafe()Description copied from class:RuleSet
Gets whether rosettes are considered safe squares in this rule set.- Specified by:
areRosettesSafe
in classRuleSet
- Returns:
- Whether rosettes are considered safe squares in this rule set.
-
doRosettesGrantExtraRolls
public boolean doRosettesGrantExtraRolls()Description copied from class:RuleSet
Gets whether landing on rosette tiles grants an additional roll.- Specified by:
doRosettesGrantExtraRolls
in classRuleSet
- Returns:
- Whether landing on rosette tiles grants an additional roll.
-
doCapturesGrantExtraRolls
public boolean doCapturesGrantExtraRolls()Description copied from class:RuleSet
Gets whether capturing a piece grants an additional roll.- Specified by:
doCapturesGrantExtraRolls
in classRuleSet
- Returns:
- Whether capturing a piece grants an additional roll.
-
generateInitialGameState
Description copied from class:RuleSet
Generates the initial state for a game.- Specified by:
generateInitialGameState
in classRuleSet
- Returns:
- The initial state for a game.
-
findAvailableMoves
Description copied from class:RuleSet
Finds all available moves from the given state.- Specified by:
findAvailableMoves
in classRuleSet
- Parameters:
board
- The current state of the board.player
- The current state of the player.roll
- The roll that was made. Must be non-zero.- Returns:
- A list of all the available moves from the given state.
-
applyRoll
public List<GameState> applyRoll(WaitingForRollGameState state, long timeSinceGameStartMs, Roll roll) Description copied from class:RuleSet
Appliesroll
tostate
to generate the new state of the game. Multiple game states may be returned to include information game states for maintaining history. However, the latest or highest-index game state will represent the state of the game after the roll was made.- Specified by:
applyRoll
in classRuleSet
- Parameters:
state
- The current state of the game.timeSinceGameStartMs
- The time that this roll took place, measured relative to the start of the game.roll
- The roll that the player made.- Returns:
- A list of new game states after the given move was made. The list may include historical information game states, and will always include the new state of the game as its last element.
-
shouldGrantExtraRoll
Determines whether the move represented bymovedState
should grant another roll to the player that made the move.- Parameters:
movedState
- The state representing a move.- Returns:
- Whether the player that made the move should be granted another roll.
-
applyMove
public List<GameState> applyMove(WaitingForMoveGameState state, long timeSinceGameStartMs, Move move) Description copied from class:RuleSet
Appliesmove
tostate
to generate the new state of the game. Multiple game states may be returned to include information game states for maintaining history. However, the latest or highest-index game state will represent the state of the game after the move was made.This method does not check that the given move is valid.
- Specified by:
applyMove
in classRuleSet
- Parameters:
state
- The current state of the game.timeSinceGameStartMs
- The time that this roll took place, measured relative to the start of the game.move
- The move that the player chose to make from this position.- Returns:
- A list of new game states after the given move was made. The list may include historical information game states, and will always include the new state of the game as its last element.
-
selectLandmarkStates
Description copied from class:RuleSet
Selects only the states that are required to reproduce exactly what happened in a game using this rule set. This is used to reduce the amount of information saved during serialisation.- Specified by:
selectLandmarkStates
in classRuleSet
- Parameters:
states
- All the states in a game.
-