pub struct GameOptions {
pub choice_atlantis: &'static str,
pub choice_olympus: &'static str,
pub atlantis_atlantis: NumberPair,
pub atlantis_olympus: NumberPair,
pub olympus_atlantis: NumberPair,
pub olympus_olympus: NumberPair,
}Expand description
This is a struct that holds the options for a game.
This struct is used to encapsulate the parameters to be used for generating a single grid from the parameters that may be related to a tournament or a series of grids.
The two parameters are:
min_value- The minimum value for that can be assigned to a choice.max_value- The maximum value for that can be assigned to a choice.
§Example
§Explicit Options
use dilemma_tactix_lib::GameOptions;
let game_options = GameOptions::new(1, 10);§Default Options
use dilemma_tactix_lib::GameOptions;
let game_options = GameOptions::default();§Builder
use dilemma_tactix_lib::GameOptions;
let game_options = GameOptions::builder("customized").build();§Notes
The GameOptions struct implements the Default trait, and can be created
with the default() method.
§See Also
Fields§
§choice_atlantis: &'static strThe label for the first choice that can be made
choice_olympus: &'static strThe label for the second choice that can be made
atlantis_atlantis: NumberPairScore for Aleph-Atlantis and Beth-Atlantis
atlantis_olympus: NumberPairScore for Aleph-Atlantis and Beth-Olympus
olympus_atlantis: NumberPairScore for Aleph-Olympus and Beth-Atlantis
olympus_olympus: NumberPairScore for Aleph-Olympus and Beth-Olympus
Implementations§
Source§impl GameOptions
impl GameOptions
Sourcepub fn new(min_value: u32, max_value: u32) -> Self
pub fn new(min_value: u32, max_value: u32) -> Self
Creates a new GameOptions struct.
This function creates a new GameOptions struct with the given
parameters.
In the implementation, the new struct instance instantiates the
ChoiceNameOptions struct, and then uses it to get a random pair of
choices. It then uses the given min_value and max_value to generate
random scores for the four possible combinations of outcomes.
§Arguments
min_value- The minimum score for that can be assigned to a choice.max_value- The maximum score for that can be assigned to a choice.
§Panics
Panics if min_value is greater than max_value.
§See Also
Sourcepub const fn choice_atlantis(&self) -> &str
pub const fn choice_atlantis(&self) -> &str
Sourcepub const fn choice_olympus(&self) -> &str
pub const fn choice_olympus(&self) -> &str
Sourcepub const fn atlantis_atlantis(&self) -> NumberPair
pub const fn atlantis_atlantis(&self) -> NumberPair
Returns the value of atlantis_atlantis.
This function returns the value of atlantis_atlantis, which is the
NumberPair containing the scores for the case when both Player Aleph
and Player Beth choose the Atlantis strategy.
§Returns
The value of atlantis_atlantis as a
NumberPair.
§See Also
Sourcepub const fn atlantis_olympus(&self) -> NumberPair
pub const fn atlantis_olympus(&self) -> NumberPair
Returns the value of atlantis_olympus.
This function returns the value of atlantis_olympus, which is the
NumberPair containing the scores for the case when Player Aleph
chooses the Atlantis strategy and Player Beth chooses the Olympus
strategy.
§Returns
The value of atlantis_olympus as a NumberPair.
§See Also
Sourcepub const fn olympus_atlantis(&self) -> NumberPair
pub const fn olympus_atlantis(&self) -> NumberPair
Returns the value of olympus_atlantis.
This function returns the value of olympus_atlantis, which is the
NumberPair containing the scores for the case when Player Aleph
chooses the Olympus strategy and Player Beth chooses the Atlantis
strategy.
§Returns
The value of olympus_atlantis as a NumberPair.
§See Also
Sourcepub const fn olympus_olympus(&self) -> NumberPair
pub const fn olympus_olympus(&self) -> NumberPair
Returns the value of olympus_olympus.
This function returns the value of olympus_olympus, which is the
NumberPair containing the scores for the case when both Player Aleph
and Player Beth choose the Olympus strategy.
§Returns
The value of olympus_olympus as a NumberPair.
§See Also
Sourcepub fn builder(builder_type: &str) -> GameOptionsBuilder
pub fn builder(builder_type: &str) -> GameOptionsBuilder
Create a builder for a GameOptions struct.
This function creates a builder for a GameOptions struct which allows
for step-by-step building of individual game options objects, bypassing
random generation of values if desired.
§Arguments
builder_type- The type of builder to create. Valid values arerandomized,seeded, andcustomized.
§Example
use dilemma_tactix_lib::GameOptions;
let game_options = GameOptions::builder("customized");§Returns
A new GameOptionsBuilder struct.
§Notes
Unlike the default method. a default builder is guaranteed to
be the same each time it is called.
§See Also
Trait Implementations§
Source§impl Clone for GameOptions
impl Clone for GameOptions
Source§fn clone(&self) -> GameOptions
fn clone(&self) -> GameOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GameOptions
impl Debug for GameOptions
Source§impl Default for GameOptions
impl Default for GameOptions
Source§fn default() -> Self
fn default() -> Self
Creates a new GameOptions struct with default values.
This function creates a new GameOptions struct with default values.
The default values are:
min_value- 1max_value- 10choice_atlantis- “cooperate”choice_olympus- “defect”
§Returns
A new GameOptions struct with default values for the parameters.
§Notes
Unlike the default options in the builder() method, the default
options here are guaranteed to generate a new random grid each time.