GameOptions

Struct GameOptions 

Source
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 str

The label for the first choice that can be made

§choice_olympus: &'static str

The label for the second choice that can be made

§atlantis_atlantis: NumberPair

Score for Aleph-Atlantis and Beth-Atlantis

§atlantis_olympus: NumberPair

Score for Aleph-Atlantis and Beth-Olympus

§olympus_atlantis: NumberPair

Score for Aleph-Olympus and Beth-Atlantis

§olympus_olympus: NumberPair

Score for Aleph-Olympus and Beth-Olympus

Implementations§

Source§

impl GameOptions

Source

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
Source

pub const fn choice_atlantis(&self) -> &str

Returns the value of choice_atlantis.

This function returns the value of choice_atlantis.

§Returns

The value of choice_atlantis.

§See Also
Source

pub const fn choice_olympus(&self) -> &str

Returns the value of choice_olympus.

This function returns the value of choice_olympus.

§Returns

The value of choice_olympus.

§See Also
Source

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
Source

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
Source

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
Source

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
Source

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 are randomized, seeded, and customized.
§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

Source§

fn clone(&self) -> GameOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GameOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GameOptions

Source§

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 - 1
  • max_value - 10
  • choice_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.

§See Also
Source§

impl Display for GameOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Implements the Display trait for GameOptions.

This function implements the Display trait for GameOptions.

Source§

impl PartialEq for GameOptions

Source§

fn eq(&self, other: &GameOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for GameOptions

Source§

impl Eq for GameOptions

Source§

impl StructuralPartialEq for GameOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V