ritchie/elements/player

Types

Player index: 0, 1, 2, 3, the player assigned east, south, west, north in the initial round.

This is forced to mod-4 arithmetic, and can represent both the absolute player index or the relative differences between the player indices.

pub type Player {
  Player(Int)
}

Constructors

  • Player(Int)

Values

pub fn add(p: Player, other: Player) -> Player
pub fn add_int(p: Player, other: Int) -> Player
pub fn all_players_from(p: Player) -> List(Player)

Returns a list of all players, starting from the given player, in natural turn order.

pub fn new(x: Int) -> Player
pub fn oppo(p: Player) -> Player

Returns the player 2 turns after the given player. In a physical game, this player would sit across the table.

pub fn other_players_after(p: Player) -> List(Player)

Returns a list of the three players after the given player, in natural turn order.

pub const p0: Player
pub const p1: Player
pub const p2: Player
pub const p3: Player
pub fn pred(p: Player) -> Player

Returns the player 1 turn before the given player. In a physical game, this player would to the left.

pub fn sub(p: Player, other: Player) -> Player
pub fn sub_int(p: Player, other: Int) -> Player
pub fn succ(p: Player) -> Player

Returns the player 1 turn after the given player. In a physical game, this player would sit to the right.

pub fn to_int(player: Player) -> Int
✨ Search Document