This commit is contained in:
vova-rs committed 2026-05-30 14:14:22 +03:00
1 parent 7cb55a9485
commit 6708bf5be6
3 files changed
+22 -1

No files matched your search

Binary file not shown.
+3
View File
@@ -28,4 +28,7 @@ impl Agent {
pub fn get_pos(&self) -> (i32, i32) { pub fn get_pos(&self) -> (i32, i32) {
self.pos.clone() self.pos.clone()
} }
pub fn get_a(&self) -> i8 {
self.ang.clone()
}
} }
+19 -1
View File
@@ -1,7 +1,7 @@
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};
mod grid; mod grid;
use std::sync::{Arc, Mutex}; use std::{fmt::format, sync::{Arc, Mutex}};
pub use grid::TorusGrid; pub use grid::TorusGrid;
@@ -124,4 +124,22 @@ impl World {
} }
} }
} }
fn debug_a(&self, n: usize) -> Option<String> {
if let Some(a) = self.agents.get(n) {
return Some(format!("pos: {:?}, ang: {:?}, id: {n}", a.get_pos(), a.get_a()));
}
None
}
pub fn debug(&self) -> String {
let mut a: String = String::new();
for i in 0..self.agents.len() {
if let Some(t) = self.debug_a(i) {
a.push_str(&t);
} else {
a.push_str("None\r\n");
}
}
a
}
} }