diff --git a/src/basic.rs b/src/basic.rs index 5c75209..0176ce8 100644 --- a/src/basic.rs +++ b/src/basic.rs @@ -30,7 +30,7 @@ impl Table { &self.data[index] } - fn get_dim(&self, x: usize, y: usize) -> &T { + pub fn get_dim(&self, x: usize, y: usize) -> &T { self.get(x + y * self.side) } diff --git a/src/seed_automation.rs b/src/seed_automation.rs index 5305c8f..54cafac 100644 --- a/src/seed_automation.rs +++ b/src/seed_automation.rs @@ -69,11 +69,13 @@ impl SeedAutomation { fn next(&mut self, rng: &mut ChaCha8Rng) { let len = (self.world.side * self.world.side) as f32; loop { - let index = (rng.random::() * len) as usize; - if *self.world.get(index) { + let x = rng.random_range(2..14); + let y = rng.random_range(2..14); + + if *self.world.get_dim(x, y) { continue; } - self.world.set(index, true); + self.world.set_dim(x, y, true); break; } }