pub struct NormalFormGame {
pub payoff_matrix_1: Array2<f64>,
pub payoff_matrix_2: Array2<f64>,
pub n_strategies_1: usize,
pub n_strategies_2: usize,
}Expand description
A 2-player normal-form game defined by payoff matrices.
Player 1 has n_strategies_1 strategies and player 2 has n_strategies_2 strategies.
payoff_matrix_1[i, j] is player 1’s payoff when player 1 plays strategy i and
player 2 plays strategy j. Analogously for payoff_matrix_2.
Fields§
§payoff_matrix_1: Array2<f64>Payoff matrix for player 1: shape (n_strategies_1, n_strategies_2)
payoff_matrix_2: Array2<f64>Payoff matrix for player 2: shape (n_strategies_1, n_strategies_2)
n_strategies_1: usizeNumber of pure strategies available to player 1
n_strategies_2: usizeNumber of pure strategies available to player 2
Implementations§
Source§impl NormalFormGame
impl NormalFormGame
Sourcepub fn zero_sum(payoff: Array2<f64>) -> Self
pub fn zero_sum(payoff: Array2<f64>) -> Self
Construct a zero-sum game from a single payoff matrix.
Player 2’s payoff is the negative of player 1’s payoff.
Sourcepub fn symmetric(payoff: Array2<f64>) -> Result<Self, OptimizeError>
pub fn symmetric(payoff: Array2<f64>) -> Result<Self, OptimizeError>
Construct a symmetric game from a single payoff matrix.
In a symmetric game, both players have the same strategy set and the payoff matrix is square. Player 2’s payoff is the transpose of player 1’s.
§Errors
Returns OptimizeError::ValueError if the matrix is not square.
Sourcepub fn payoff(&self, s1: usize, s2: usize) -> (f64, f64)
pub fn payoff(&self, s1: usize, s2: usize) -> (f64, f64)
Get the payoff pair for a pure strategy profile.
§Returns
(payoff_1, payoff_2) for the given strategy indices.
Sourcepub fn expected_payoff(
&self,
mixed_1: &[f64],
mixed_2: &[f64],
) -> Result<(f64, f64), OptimizeError>
pub fn expected_payoff( &self, mixed_1: &[f64], mixed_2: &[f64], ) -> Result<(f64, f64), OptimizeError>
Trait Implementations§
Source§impl Clone for NormalFormGame
impl Clone for NormalFormGame
Source§fn clone(&self) -> NormalFormGame
fn clone(&self) -> NormalFormGame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NormalFormGame
impl RefUnwindSafe for NormalFormGame
impl Send for NormalFormGame
impl Sync for NormalFormGame
impl Unpin for NormalFormGame
impl UnsafeUnpin for NormalFormGame
impl UnwindSafe for NormalFormGame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.