ritchie/engine/utils
Shared helpers for the engine.
Values
pub fn calc_nagashi_mangan_delta(
nagashi_players: List(player.Player),
button: player.Player,
) -> List(Int)
Calculates the payments for one or more nagashi mangan winners.
pub fn calc_pot_delta(
riichi_flags: List(option.Option(riichi.Riichi)),
) -> List(Int)
Calculates the point deltas for each player who has declared riichi.
pub fn calc_wall_exhausted_delta(waiting: List(Int)) -> List(Int)
Calculates the penalty deltas for a normal exhaustive draw.
pub fn ensure(condition: Bool, error: e) -> Result(Nil, e)
Returns Ok(Nil) when the condition is true, otherwise returns the given error.
pub fn is_aborted_four_kan(
state: state.State,
act: action.Action,
resolved_reaction: option.Option(reaction.Reaction),
) -> Bool
Is this action/reaction the fourth kan?
pub fn is_aborted_four_riichi(
state: state.State,
act: action.Action,
) -> Bool
Is this discard the fourth riichi declaration?
pub fn is_aborted_four_wind(
state: state.State,
act: action.Action,
) -> Bool
Is this discard the fourth consecutive wind?
pub fn is_ankan_ok_under_riichi(
rules: rules.Ruleset,
pre_draw_hand: tile_set37.TileSet37,
merged_hand: tile_set37.TileSet37,
melds: List(meld.Meld),
draw: option.Option(tile.Tile),
ankan: tile.Tile,
) -> Bool
Is an ankan legal while under riichi?
pub fn is_first_chance(state: state.State) -> Bool
Are we in the first four turns of the round (without being interrupted by any meld)?
pub fn is_forbidden_swap_call(
rules: rules.Ruleset,
called_meld: meld.Meld,
discard_tile: tile.Tile,
) -> Bool
Is a discard immediately after calling chii/pon considered a swap call?
pub fn is_kokushi_wait(
hand: tile_set37.TileSet37,
melds: List(meld.Meld),
winning_tile: tile.Tile,
) -> Bool
Whether the hand is waiting on this tile as kokushi musou.
pub fn is_last_draw(state: state.State) -> Bool
Are there any more draws available? This is the prerequisite condition for yakus haitei and houtei.
pub fn is_nagashi_mangan(
state: state.State,
p: player.Player,
) -> Bool
Does the player qualify for nagashi mangan at an exhaustive draw?
pub fn num_active_riichi(state: state.State) -> Int
Number of players currently under riichi.
pub fn num_draws(state: state.State) -> Int
Returns the total number of tiles drawn from the wall, including the initial deal.
pub fn player_at(items: List(a), p: player.Player) -> a
Returns the player at the specified position in the player list.
pub fn terminal_kinds(hand: tile_set37.TileSet37) -> Int
Returns the number of distinct terminal and honor kinds in a hand.