pub struct EloPlayer {
    pub elo: (f32, u16),
    pub age: u8,
    /* private fields */
}
Expand description

The player necessary for a Elo evaluation.

Fields§

§elo: (f32, u16)§age: u8

Implementations§

source§

impl EloPlayer

source

pub fn new(elo: (f32, u16), age: u8) -> EloPlayer

Create a new player.

Arguments
  • elo: (f32, u16) - The rating. f32 is the actual rating, u16 the index which indicates the played matches.
  • age: u8 - The age of the player.
Examples
use lib_rapid::math::ratings::elo::player::EloPlayer;
 
let mut player = EloPlayer::new((2306.0, 32), 43);
source

pub fn update_rating(&mut self, opponent_rating: f32, scored: f32)

Update a player’s rating.

Arguments
  • opponent_ratings: Vec<f32> - All the opponent’s ratings without the index.
  • scored: f32 - The scored points. 1 is a win, 0.5 a draw and 0 a loss.
Examples
use lib_rapid::math::ratings::elo::player::EloPlayer;
 
let mut player = EloPlayer::new((2306.0, 32), 43);
player.update_rating(2077.0, 0.0);
 
assert_eq!(2290.0, player.elo.0.round());

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.