rearrange and connect towns (shows planning weakness)

This commit is contained in:
Christof Petig 2022-03-27 23:43:32 +02:00
parent faf12118f0
commit 6f431a6fff

View File

@ -513,22 +513,22 @@ mod tests {
rng,
targets: hashbrown::HashMap::new(),
};
add_settlement(&mut env, "Grass", 18.0, &[(
Good::Terrain(BiomeKind::Grassland),
100.0_f32,
)]);
add_settlement(&mut env, "Forest", 22.0, &[(
Good::Terrain(BiomeKind::Forest),
100.0_f32,
)]);
add_settlement(&mut env, "Mountain", 19.0, &[(
Good::Terrain(BiomeKind::Mountain),
100.0_f32,
)]);
add_settlement(&mut env, "Desert", 19.0, &[(
Good::Terrain(BiomeKind::Desert),
add_settlement(&mut env, "Grass", 18.0, &[(
Good::Terrain(BiomeKind::Grassland),
100.0_f32,
)]);
// add_settlement(&mut env, "Mountain", 19.0, &[(
// Good::Terrain(BiomeKind::Mountain),
// 100.0_f32,
// )]);
// add_settlement(&mut env, "Desert", 19.0, &[(
// Good::Terrain(BiomeKind::Desert),
// 100.0_f32,
// )]);
// add_settlement(&mut index, &mut rng, &[
// (Good::Terrain(BiomeKind::Jungle), 100.0_f32),
// ]);
@ -540,10 +540,25 @@ mod tests {
(Good::Terrain(BiomeKind::Forest), 100.0_f32),
(Good::Terrain(BiomeKind::Mountain), 10.0_f32),
]);
add_settlement(&mut env, "MountainCave", 19.0, &[
add_settlement(&mut env, "Mountain", 19.0, &[
(Good::Terrain(BiomeKind::Mountain), 100.0_f32),
// (Good::CaveAccess, 100.0_f32),
]);
// connect to neighbors
for i in 1..(env.index.sites.ids().count() as u64 - 1) {
let previous = env.index.sites.recreate_id(i - 1);
let next = env.index.sites.recreate_id(i + 1);
let center = env.index.sites.recreate_id(i);
center
.zip(previous)
.zip(next)
.map(|((center, previous), next)| {
env.index.sites[center].economy.add_neighbor(next, 1);
env.index.sites[next].economy.add_neighbor(center, 1);
env.index.sites[center].economy.add_neighbor(previous, 2);
env.index.sites[previous].economy.add_neighbor(center, 2);
});
}
crate::sim2::simulate(&mut env.index, &mut sim);
use crate::site::economy::good_list;
for (id, site) in env.index.sites.iter() {