merge origin/dev-vorld in new branch lemon-debug-agent

This commit is contained in:
lemon-cat committed 2026-05-30 15:18:37 +03:00
commit 021d91d1ea
3 files changed
+29 -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()
}
} }
+26 -1
View File
@@ -1,7 +1,10 @@
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 +127,26 @@ 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
}
} }