View Source Briscola.Strategy.Simulator (Briscola v0.1.1)

A module for simulating games of Briscola using different strategies.

Summary

Functions

Create a new simulator with a game and a list of strategies. Player 0 will use the first strategy, player 1 the second, and so on.

Simulate until the game is over.

Simulate a single turn in the game. That may mean playing a card, scoring a trick then redealing, or ending the game.

Types

log_message()

@type log_message() ::
  {:game_over, [Briscola.Player.t()]}
  | {:trick_winner, integer()}
  | {:player_turn, integer(), Briscola.Card.t()}
  | {:start, Briscola.Game.t()}

new_options()

@type new_options() :: [{:on_message, (Briscola.Game.t(), log_message() -> any())}]

t()

@type t() :: %Briscola.Strategy.Simulator{
  game: Briscola.Game.t(),
  log: [log_message()],
  on_message: (log_message() -> any()),
  strategies: [module()]
}

Functions

new(game, strategies, opts \\ [])

Create a new simulator with a game and a list of strategies. Player 0 will use the first strategy, player 1 the second, and so on.

run(sim)

Simulate until the game is over.

sim_turn(sim)

Simulate a single turn in the game. That may mean playing a card, scoring a trick then redealing, or ending the game.