pub struct FinalScoreSimulator;Expand description
§FinalScoreSimulator struct
A FinalScoreSimulator generates an american football final score
given the normalized skill differential (in range [0, 1]) of the
home offense and the away defense, and vice versa, the away
offense and the home defense.
Implementations§
Source§impl FinalScoreSimulator
impl FinalScoreSimulator
Sourcepub fn new() -> FinalScoreSimulator
pub fn new() -> FinalScoreSimulator
Constructor for the FinalScoreSimulator struct
§Example
use fbsim_core::game::score::FinalScoreSimulator;
let my_sim = FinalScoreSimulator::new();Sourcepub fn sim(
&self,
home_team: &impl ScoreSimulatable,
away_team: &impl ScoreSimulatable,
rng: &mut impl Rng,
) -> Result<FinalScore, String>
pub fn sim( &self, home_team: &impl ScoreSimulatable, away_team: &impl ScoreSimulatable, rng: &mut impl Rng, ) -> Result<FinalScore, String>
Simulates a game by generating a final score result
§Example
use fbsim_core::game::score::{FinalScore, FinalScoreSimulator};
use fbsim_core::team::FootballTeam;
let home = FootballTeam::new();
let away = FootballTeam::new();
let sim = FinalScoreSimulator::new();
let mut rng = rand::thread_rng();
let score = sim.sim(&home, &away, &mut rng).unwrap();
println!("{}", score);Trait Implementations§
Source§impl Clone for FinalScoreSimulator
impl Clone for FinalScoreSimulator
Source§fn clone(&self) -> FinalScoreSimulator
fn clone(&self) -> FinalScoreSimulator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FinalScoreSimulator
impl Debug for FinalScoreSimulator
Source§impl Default for FinalScoreSimulator
impl Default for FinalScoreSimulator
Source§fn default() -> FinalScoreSimulator
fn default() -> FinalScoreSimulator
Returns the “default value” for a type. Read more
Source§impl PartialEq for FinalScoreSimulator
impl PartialEq for FinalScoreSimulator
Source§impl PartialOrd for FinalScoreSimulator
impl PartialOrd for FinalScoreSimulator
impl Copy for FinalScoreSimulator
impl StructuralPartialEq for FinalScoreSimulator
Auto Trait Implementations§
impl Freeze for FinalScoreSimulator
impl RefUnwindSafe for FinalScoreSimulator
impl Send for FinalScoreSimulator
impl Sync for FinalScoreSimulator
impl Unpin for FinalScoreSimulator
impl UnwindSafe for FinalScoreSimulator
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.