Skip to content

Commit

Permalink
use const for probability
Browse files Browse the repository at this point in the history
  • Loading branch information
wooster0 committed Aug 21, 2021
1 parent dbe0edf commit 085c055
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/grid/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ use rand::SeedableRng;
use super::{Cell, Grid};
use terminal::util::Size;

const PROBABILITY: f64 = 0.75;

fn random_cells(size: u32) -> Vec<Cell> {
let mut cells = Vec::<Cell>::with_capacity(size as usize);
let mut small_rng = SmallRng::from_entropy();
let distribution = Bernoulli::new(0.75).unwrap();

let distribution = Bernoulli::new(PROBABILITY);
let distribution = distribution.unwrap(); // `PROBABILITY` is in range 0 to 1

for _ in 0..size {
let filled = distribution.sample(&mut small_rng);
Expand Down

0 comments on commit 085c055

Please sign in to comment.