continue work on simulation

This commit is contained in:
2019-03-06 23:31:03 -05:00
parent 7357fe7df0
commit cd548eaa01
6 changed files with 357 additions and 27 deletions

34
src/simulation.rs Normal file
View File

@@ -0,0 +1,34 @@
use rand::seq::SliceRandom;
use crate::nhlapi::LeagueRecord;
#[derive(Debug, Copy, Clone)]
struct Entry {
team_id: u32,
division_id: u32,
conference_id: u32,
wins: u32,
losses: u32,
ot: u32,
points: u32,
}
#[derive(Debug, Copy, Clone)]
enum Event {
Win,
Loss,
Ot,
}
fn random_event(rec: &LeagueRecord) -> Event {
[
(Event::Win, rec.wins),
(Event::Loss, rec.losses),
(Event::Ot, rec.ot),
]
.choose_weighted(&mut rand::thread_rng(), |x| x.1)
.unwrap()
.0
}
pub struct Simulation {}