pub struct Match<'a> {
pub result: f32,
/* private fields */
}
Expand description
A match between two opponents.
Fields§
§result: f32
1: Player one wins. 0: Player two wins.
Implementations§
source§impl Match<'_>
impl Match<'_>
sourcepub fn new<'a>(
player_one: &'a mut EloPlayer,
player_two: &'a mut EloPlayer,
result: f32
) -> Match<'a>
pub fn new<'a>( player_one: &'a mut EloPlayer, player_two: &'a mut EloPlayer, result: f32 ) -> Match<'a>
Creates a new match between two players.
Arguments
player_one: &'a mut EloPlayer
- The first player.player_two: &'a mut EloPlayer
- The second player.result: f32
- The result. 1: Player one wins. 0: Player two wins.
Returns
A new Match<'a>
.
Examples
use lib_rapid::math::ratings::elo::{player::EloPlayer, p_match::Match};
let mut beth = EloPlayer::new((1193.0, 1), 18);
let mut eric = EloPlayer::new((1213.0, 1), 25);
let mut first_match = Match::new(&mut beth, &mut eric, -1.0); // -1.0 is used here for not yet decided
sourcepub fn update_ratings(&mut self)
pub fn update_ratings(&mut self)
Update the ratings of both players.
Examples
use lib_rapid::math::ratings::elo::{player::EloPlayer, p_match::Match};
let mut beth = EloPlayer::new((1193.0, 1), 18);
let mut eric = EloPlayer::new((1213.0, 1), 25);
let mut first_match = Match::new(&mut beth, &mut eric, -1.0); // -1.0 is used here for not yet decided
first_match.result = 1.0; // Beth wins
first_match.update_ratings();
assert_eq!(1214.0, beth.elo.0.round());
assert_eq!(1192.0, eric.elo.0.round());
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Match<'a>
impl<'a> Send for Match<'a>
impl<'a> Sync for Match<'a>
impl<'a> Unpin for Match<'a>
impl<'a> !UnwindSafe for Match<'a>
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