report math
cargo devel CI / cargo CI (push) Successful in 1m37s Details

This commit is contained in:
Christoph J. Scherr 2024-04-05 12:07:01 +02:00
parent 29a6c984ae
commit 628d5b6b96
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
1 changed files with 19 additions and 33 deletions

View File

@ -9,9 +9,9 @@ use serde::{Deserialize, Serialize};
use crate::game::response::GuessResponse; use crate::game::response::GuessResponse;
pub const WEIGHTING_SCORE: f64 = 0.9; pub const WEIGHTING_SCORE: f64 = 0.6;
pub const WEIGHTING_TIME: f64 = 0.1; pub const WEIGHTING_TIME: f64 = 0.1;
pub const WEIGHTING_WIN: f64 = 0.0; pub const WEIGHTING_WIN: f64 = 0.3;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct Report { pub struct Report {
@ -70,38 +70,24 @@ impl Report {
Some(av) Some(av)
} }
pub fn rating(&self) -> Option<f64> { fn rating_score(&self) -> f64 {
assert_eq!(WEIGHTING_WIN + WEIGHTING_SCORE + WEIGHTING_TIME, 1.0);
debug!(
"partial rating - score: {}",
WEIGHTING_SCORE * self.avg_score() WEIGHTING_SCORE * self.avg_score()
); }
debug!(
"partial rating - win: {}", fn rating_win(&self) -> f64 {
WEIGHTING_WIN * (1.0 - self.avg_win()) WEIGHTING_WIN * (1.0 - self.avg_win()) * 10.0
); }
// FIXME: this is not normalized, which can lead to negative score
debug!( fn rating_time(&self) -> Option<f64> {
"partial rating - time: {}", Some(WEIGHTING_TIME * self.avg_time()?.num_nanoseconds()? as f64 / 100000.0)
WEIGHTING_TIME }
* (1.0
- (1_000_000_000.0 pub fn rating(&self) -> Option<f64> {
/ self assert_eq!((WEIGHTING_WIN + WEIGHTING_SCORE + WEIGHTING_TIME).round(), 1.0);
.avg_time()? debug!("partial rating - score: {}", self.rating_score());
.num_nanoseconds() debug!("partial rating - win: {}", self.rating_win());
.expect("took so many ns per game that an integer overflow occured") debug!("partial rating - time: {:?}", self.rating_time()?);
as f64)) let r = self.rating_win() + self.rating_time()? + self.rating_score();
);
let r = WEIGHTING_SCORE * self.avg_score()
+ WEIGHTING_WIN * (1.0 - self.avg_win())
+ WEIGHTING_TIME
* (1.0
- (1_000_000_000.0
/ self
.avg_time()?
.num_nanoseconds()
.expect("took so many ns per game that an integer overflow occured")
as f64));
Some(r) Some(r)
} }