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
ConstructorsConstructorDescriptionSimpleRuleSet(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) Appliesmovetostateto generate the new state of the game.applyRoll(WaitingForRollGameState state, long timeSinceGameStartMs, Roll roll) Appliesrolltostateto generate the new state of the game.booleanGets whether rosettes are considered safe squares in this rule set.booleanGets whether capturing a piece grants an additional roll.booleanGets 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.booleanshouldGrantExtraRoll(MovedGameState movedState) Determines whether the move represented bymovedStateshould 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:RuleSetGets whether rosettes are considered safe squares in this rule set.- Specified by:
areRosettesSafein classRuleSet- Returns:
- Whether rosettes are considered safe squares in this rule set.
-
doRosettesGrantExtraRolls
public boolean doRosettesGrantExtraRolls()Description copied from class:RuleSetGets whether landing on rosette tiles grants an additional roll.- Specified by:
doRosettesGrantExtraRollsin classRuleSet- Returns:
- Whether landing on rosette tiles grants an additional roll.
-
doCapturesGrantExtraRolls
public boolean doCapturesGrantExtraRolls()Description copied from class:RuleSetGets whether capturing a piece grants an additional roll.- Specified by:
doCapturesGrantExtraRollsin classRuleSet- Returns:
- Whether capturing a piece grants an additional roll.
-
generateInitialGameState
Description copied from class:RuleSetGenerates the initial state for a game.- Specified by:
generateInitialGameStatein classRuleSet- Returns:
- The initial state for a game.
-
findAvailableMoves
Description copied from class:RuleSetFinds all available moves from the given state.- Specified by:
findAvailableMovesin 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:RuleSetAppliesrolltostateto 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:
applyRollin 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 bymovedStateshould 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:RuleSetAppliesmovetostateto 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:
applyMovein 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:RuleSetSelects 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:
selectLandmarkStatesin classRuleSet- Parameters:
states- All the states in a game.
-