Crate prisoner

Source
Expand description

An example game can be expressed using the library types:

let mut players = prisoner::make_players(args.players);
prisoner::play_game(&mut players, args.rounds.unwrap_or(1));
let output_table = Table::new(players)
    .with(Style::rounded())
    // .with(Modify::new(Rows::single(1)).with(Border::default().top('x')))
    .to_string();
print!("{}", output_table)

Providing more than one round initiates a “tournament”, where round-robin will occur per number of rounds.

Modules§

entity
Entity is a concrete base type and Player implementation

Enums§

Choice
In every roound the player can only make one of two choices, CHEAT, or COOPERATE
Outcome
Outcome represents results of the game. There can only be these four results. Different scoring implementations of functions can be applied.

Functions§

determine
At the heart of the prisoners dilemma is the choice between two players they can choose to COOPERATE or CHEAT (or BETRAY, etc). The possible outcomes can be found here: https://en.wikipedia.org/wiki/Prisoner%27s_dilemma