chore(simulation): cargo fmt atlas modules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,7 +99,11 @@ fn cell_score(
|
||||
let row = role_row(&city.economic_role);
|
||||
let col = attractor_col(&attractor.attractor_type);
|
||||
let weight = matrix.weights[row][col];
|
||||
let cost_factor = if terrain_cost > 0.0 { 1.0 / terrain_cost } else { 1.0 };
|
||||
let cost_factor = if terrain_cost > 0.0 {
|
||||
1.0 / terrain_cost
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
weight * attractor.strength * cost_factor
|
||||
}
|
||||
|
||||
@@ -213,11 +217,7 @@ fn hungarian(cost: &[Vec<f32>]) -> Vec<usize> {
|
||||
/// Minimum pixel separation between synthetic attractor positions.
|
||||
const MIN_SPACING: u16 = 15;
|
||||
|
||||
fn synthetic_attractor(
|
||||
placed: &[CityPlacement],
|
||||
grid_w: u32,
|
||||
grid_h: u32,
|
||||
) -> GeographicAttractor {
|
||||
fn synthetic_attractor(placed: &[CityPlacement], grid_w: u32, grid_h: u32) -> GeographicAttractor {
|
||||
// Place at grid center as default, then walk until spacing is satisfied.
|
||||
let mut row = (grid_h / 2) as u16;
|
||||
let mut col = (grid_w / 4) as u16;
|
||||
@@ -326,9 +326,7 @@ pub fn match_cities(
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(i, c)| {
|
||||
!tier_a_indices.contains(i)
|
||||
&& c.population >= 50_000
|
||||
&& c.population < 1_000_000
|
||||
!tier_a_indices.contains(i) && c.population >= 50_000 && c.population < 1_000_000
|
||||
})
|
||||
.map(|(i, _)| i)
|
||||
.collect();
|
||||
@@ -450,12 +448,12 @@ pub fn founding_orientation(
|
||||
coastal_facing: u16,
|
||||
) -> FoundingOrientation {
|
||||
match attractor_type {
|
||||
AttractorType::RiverMouth | AttractorType::CoastalAccess => {
|
||||
FoundingOrientation::Coastal { facing_degrees: coastal_facing }
|
||||
}
|
||||
AttractorType::RiverCrossing => {
|
||||
FoundingOrientation::RiverAligned { bearing_degrees: river_bearing }
|
||||
}
|
||||
AttractorType::RiverMouth | AttractorType::CoastalAccess => FoundingOrientation::Coastal {
|
||||
facing_degrees: coastal_facing,
|
||||
},
|
||||
AttractorType::RiverCrossing => FoundingOrientation::RiverAligned {
|
||||
bearing_degrees: river_bearing,
|
||||
},
|
||||
AttractorType::ValleyFloor => FoundingOrientation::TerrainFollowing,
|
||||
AttractorType::PlainCenter => {
|
||||
if matches!(territorial_status, TerritorialStatus::CommissionControlled) {
|
||||
@@ -480,11 +478,17 @@ mod tests {
|
||||
use crate::simulation::generator::{CompatibilityMatrix, GeographicAttractor};
|
||||
|
||||
fn uniform_matrix() -> CompatibilityMatrix {
|
||||
CompatibilityMatrix { weights: [[1.0; 7]; 10] }
|
||||
CompatibilityMatrix {
|
||||
weights: [[1.0; 7]; 10],
|
||||
}
|
||||
}
|
||||
|
||||
fn make_attractor(row: u16, col: u16, at: AttractorType, strength: f32) -> GeographicAttractor {
|
||||
GeographicAttractor { position: (row, col), attractor_type: at, strength }
|
||||
GeographicAttractor {
|
||||
position: (row, col),
|
||||
attractor_type: at,
|
||||
strength,
|
||||
}
|
||||
}
|
||||
|
||||
fn make_city(id: u64, class: SettlementClass, pop: i64) -> CityRecord {
|
||||
@@ -517,7 +521,7 @@ mod tests {
|
||||
make_city(2, SettlementClass::PopulationBudget, 200_000),
|
||||
];
|
||||
let attractors = vec![
|
||||
make_attractor(5, 5, AttractorType::RiverMouth, 0.9), // best
|
||||
make_attractor(5, 5, AttractorType::RiverMouth, 0.9), // best
|
||||
make_attractor(10, 10, AttractorType::ValleyFloor, 0.4), // second
|
||||
];
|
||||
let matrix = uniform_matrix();
|
||||
@@ -597,7 +601,12 @@ mod tests {
|
||||
use crate::simulation::generator::TerritorialStatus;
|
||||
let status = TerritorialStatus::FrontierUnclaimed;
|
||||
let o = founding_orientation(&AttractorType::RiverMouth, &status, 90, 270);
|
||||
assert!(matches!(o, FoundingOrientation::Coastal { facing_degrees: 270 }));
|
||||
assert!(matches!(
|
||||
o,
|
||||
FoundingOrientation::Coastal {
|
||||
facing_degrees: 270
|
||||
}
|
||||
));
|
||||
|
||||
let o2 = founding_orientation(
|
||||
&AttractorType::PlainCenter,
|
||||
@@ -607,12 +616,7 @@ mod tests {
|
||||
);
|
||||
assert!(matches!(o2, FoundingOrientation::Cardinal));
|
||||
|
||||
let o3 = founding_orientation(
|
||||
&AttractorType::ValleyFloor,
|
||||
&status,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
let o3 = founding_orientation(&AttractorType::ValleyFloor, &status, 0, 0);
|
||||
assert!(matches!(o3, FoundingOrientation::TerrainFollowing));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user