refactor(simulation): address PR #72 review suggestions
- Hoshe #3: replace O(n²) Vec scan in fallback NPC assignment with BTreeSet; prevent same NPC assigned to two roles in one triangle - Hoshe #4: add From impls for RoleId, TriangleId, StableId, and TriangleCrisisEventWire — eliminate fragile .0 access on newtypes - Hoshe #5: consolidate near-identical unit tests with integration counterparts — keep only unique tests in #[cfg(test)] module - Tyre #3: replace O(N*M) scan in apply_resolve_triangle with BTreeMap<TriangleId, Entity> index for O(1) per-command lookup - Tyre #4: document &mut World on generate_intra_template_triangles - Observer snapshot uses TriangleCrisisEventWire::from instead of manual field mapping Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,12 @@ use crate::simulation::movement::TilePosition;
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct StableId(pub u64);
|
||||
|
||||
impl From<StableId> for u64 {
|
||||
fn from(id: StableId) -> Self {
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Typed fact identifier for non-entity knowledge.
|
||||
/// Format: "category.topic" (e.g., "contraband.ring_exists").
|
||||
/// Lexicographic ordering in BTreeMap provides deterministic iteration.
|
||||
|
||||
Reference in New Issue
Block a user