Daniel Sanchez ff2c1b4271
Restructure crates (#24)
* Rename to netrunner

* Refactor sims structure

* Add missing workspace cargo

* Rebase changes

* Rebase changes

* Rebase changes

* Fix tests
2024-11-07 06:05:56 +01:00

23 lines
371 B
Rust

use rand::Rng;
pub struct StakeLottery<R> {
rng: R,
stake_proportion: f64,
}
impl<R> StakeLottery<R>
where
R: Rng,
{
pub fn new(rng: R, stake_proportion: f64) -> Self {
Self {
rng,
stake_proportion,
}
}
pub fn run(&mut self) -> bool {
self.rng.gen_range(0.0..1.0) < self.stake_proportion
}
}