ritchie/model/boundary

Boundary conditions of a round, its beginning and its end.

Types

Meta-states at the beginning of a round.

pub type RoundBegin {
  RoundBegin(
    ruleset: rules.Ruleset,
    round_id: RoundId,
    wall: wall.Wall,
    pot: Int,
    points: List(Int),
  )
}

Constructors

  • RoundBegin(
      ruleset: rules.Ruleset,
      round_id: RoundId,
      wall: wall.Wall,
      pot: Int,
      points: List(Int),
    )

    Arguments

    wall

    The full 136-tile wall right after shuffling and cutting. Drawing and revealing (of dora indicators) are “virtual”, always referring to this original wall.

    pot

    Points left on the table, up for grabs by the next winner. Commonly 1000-pt sticks from riichi.

    points

    Points for each player, indexed by player.to_int.

Details of how a round concluded.

pub type RoundEnd {
  RoundEnd(
    round_result: action_result.ActionResult,
    pot: Int,
    points: List(Int),
    points_delta: List(Int),
    renchan: Bool,
    next_round_id: option.Option(RoundId),
    agari_result: List(option.Option(agari_result.AgariResult)),
  )
}

Constructors

  • RoundEnd(
      round_result: action_result.ActionResult,
      pot: Int,
      points: List(Int),
      points_delta: List(Int),
      renchan: Bool,
      next_round_id: option.Option(RoundId),
      agari_result: List(option.Option(agari_result.AgariResult)),
    )

    Arguments

    round_result

    The terminal action result of the round.

    pot

    Points left on the table at round end.

    points

    Points for each player at round end.

    points_delta

    Point increments for each player (end - begin).

    renchan

    Whether the next round is “this round + 1 honba”.

    next_round_id

    The next round, or None if the game ends.

    agari_result

    How each player won, if they did.

“Ba-Kyoku-Honba” triplet that identifies a round.

pub type RoundId {
  RoundId(kyoku: Int, honba: Int)
}

Constructors

  • RoundId(kyoku: Int, honba: Int)

    Arguments

    kyoku

    Round index together with the prevailing wind.

    • 0 => east 1, 3 => east 4
    • 4 => south 1, 7 => south 4
    • 8 => west 1, 15 => north 4
    honba

    Number of honba, commonly shown as 100-point sticks.

Values

pub fn button(round_id: RoundId) -> player.Player

Returns the index of the dealer.

pub fn next_honba(round_id: RoundId, renchan: Bool) -> RoundId

Returns the next sub-round. This happens when the dealer wins (renchan == true) or the round is aborted without a dealer change.

pub fn next_kyoku(round_id: RoundId) -> RoundId

Returns the next real round, resetting honba.

pub fn player_with_self_wind(
  round_id: RoundId,
  wind: player.Player,
) -> player.Player

Returns the index of the player with the given self wind.

pub fn prevailing_wind(round_id: RoundId) -> player.Player

Returns the index of the prevailing wind, shared by all players.

pub fn self_wind_for_player(
  round_id: RoundId,
  p: player.Player,
) -> player.Player

Returns the index of the self wind of a player.

✨ Search Document