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 is a concrete base type and Player implementation
Enums
- In every roound the player can only make one of two choices, CHEAT, or COOPERATE
- Outcome represents results of the game. There can only be these four results. Different scoring implementations of functions can be applied.
Functions
- 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
- make_players will assemble a Vector of basic entities using fake data and a random distribution of personalities
- play_game determines what kind of game to play, 0 or 1 will be a straight round robin, anything more will be round robin with multiple rounds