diff --git a/src/grid.rs b/src/grid.rs index 03e6c92..4954960 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -1,3 +1,5 @@ +mod rand; + #[derive(Clone, Default, Debug, PartialEq)] pub enum Cell { /// Filled. diff --git a/src/grid/rand.rs b/src/grid/rand.rs new file mode 100644 index 0000000..23bd419 --- /dev/null +++ b/src/grid/rand.rs @@ -0,0 +1,14 @@ +use crate::grid::Cell; +use rand::distributions::{Distribution, Standard}; +use rand::Rng; + +impl Distribution for Standard { + fn sample(&self, rng: &mut R) -> Cell { + let filled = rng.gen_bool(2. / 3.); + if filled { + Cell::Filled + } else { + Cell::Empty + } + } +}