mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed biasing bug
This commit is contained in:
parent
59f8c4a96b
commit
1c91940397
@ -110,14 +110,14 @@ impl Site {
|
||||
}
|
||||
|
||||
pub fn find_roadside_aabr(&mut self, rng: &mut impl Rng, area_range: Range<u32>, min_dims: Extent2<u32>) -> Option<(Aabr<i32>, Vec2<i32>)> {
|
||||
let dir = Vec2::<f32>::zero().map(|_| rng.gen_range(-1.0..1.0));
|
||||
let dir = Vec2::<f32>::zero().map(|_| rng.gen_range(-1.0..1.0)).normalized();
|
||||
let search_pos = if rng.gen() {
|
||||
self.plot(*self.plazas.choose(rng).unwrap()).root_tile + (dir * 5.0).map(|e: f32| e.round() as i32)
|
||||
self.plot(*self.plazas.choose(rng)?).root_tile + (dir * 5.0).map(|e: f32| e.round() as i32)
|
||||
} else {
|
||||
if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind {
|
||||
*path.nodes().choose(rng)? + (dir * 1.5).map(|e: f32| e.round() as i32)
|
||||
} else {
|
||||
return None;
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
|
||||
@ -128,7 +128,7 @@ impl Site {
|
||||
let pos = attempt(32, || {
|
||||
self.plazas
|
||||
.choose(rng)
|
||||
.map(|&p| self.plot(p).root_tile + Vec2::new(rng.gen_range(-24..24), rng.gen_range(-24..24)))
|
||||
.map(|&p| self.plot(p).root_tile + Vec2::new(rng.gen_range(-20..20), rng.gen_range(-20..20)))
|
||||
.filter(|&tile| self
|
||||
.plazas
|
||||
.iter()
|
||||
@ -186,7 +186,7 @@ impl Site {
|
||||
let mut castles = 0;
|
||||
|
||||
for _ in 0..1000 {
|
||||
if site.plots.len() > 80 {
|
||||
if site.plots.len() - site.plazas.len() > 80 {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,8 @@ impl TileGrid {
|
||||
} else if aabr.size().product() + if i % 2 == 0 { aabr.size().h } else { aabr.size().w } > area_range.end as i32 {
|
||||
break;
|
||||
} else {
|
||||
match i % 4 {
|
||||
// `center.sum()` to avoid biasing certain directions
|
||||
match (i + center.sum().abs()) % 4 {
|
||||
0 if (aabr.min.y..aabr.max.y + 1).all(|y| self.get(Vec2::new(aabr.max.x, y)).is_empty()) => {
|
||||
aabr.max.x += 1;
|
||||
last_growth = i;
|
||||
|
Loading…
Reference in New Issue
Block a user