Better seed generation
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ impl<T: Clone> Table<T> {
|
|||||||
&self.data[index]
|
&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)
|
self.get(x + y * self.side)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,11 +69,13 @@ impl SeedAutomation {
|
|||||||
fn next(&mut self, rng: &mut ChaCha8Rng) {
|
fn next(&mut self, rng: &mut ChaCha8Rng) {
|
||||||
let len = (self.world.side * self.world.side) as f32;
|
let len = (self.world.side * self.world.side) as f32;
|
||||||
loop {
|
loop {
|
||||||
let index = (rng.random::<f32>() * len) as usize;
|
let x = rng.random_range(2..14);
|
||||||
if *self.world.get(index) {
|
let y = rng.random_range(2..14);
|
||||||
|
|
||||||
|
if *self.world.get_dim(x, y) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self.world.set(index, true);
|
self.world.set_dim(x, y, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user