add local itention for agent

This commit is contained in:
lemon-cat committed 2026-05-26 13:01:56 +03:00
1 parent c6b1b68572
commit d4cfb25c8d
2 files changed
+11 -7

No files matched your search

+1 -3
View File
@@ -2,18 +2,16 @@
// use super::{MagicContainer, MCError}; // use super::{MagicContainer, MCError};
// use super::TorusGrid; // use super::TorusGrid;
#[derive(Clone)] #[derive(Clone)]
pub enum Intention { pub enum Intention {
MoveTo, MoveTo,
StakedOut, StakedOut,
} }
#[derive(Clone)] #[derive(Clone)]
pub enum LocalItentoin { pub enum LocalItentoin {
Rotate(i8), Rotate(i8),
SwapCell, SwapCell((i32, i32)),
} }
#[derive(Clone)] #[derive(Clone)]
+10 -4
View File
@@ -53,17 +53,23 @@ impl World {
&self.a_grid &self.a_grid
} }
pub fn update(&mut self) { pub fn update(&mut self) {
let mut plane_of_intentions: TorusGrid<SmallVec<[LinkIntention<Intention>; 4]>> = TorusGrid::new(SmallVec::new(), self.size.clone()); let mut plane_of_intentions: TorusGrid<SmallVec<[LinkIntention<Intention>; 4]>> =
TorusGrid::new(SmallVec::new(), self.size.clone());
let mut local_it: Vec<LinkIntention<LocalItentoin>> = Vec::new(); let mut local_it: Vec<LinkIntention<LocalItentoin>> = Vec::new();
for i in 0..self.agents.len() { for i in 0..self.agents.len() {
if let Some(ag) = self.agents.get(i) { if let Some(ag) = self.agents.get(i) {
let cell = self.grid.get_wrap(ag.get_pos()); let cell = self.grid.get_wrap(ag.get_pos());
local_it.push(LinkIntention {
it: LocalItentoin::Rotate((-1 * *cell as i8) + (1 * !*cell as i8)),
lin: i,
});
local_it.push(LinkIntention {
it: LocalItentoin::SwapCell(ag.get_pos()),
lin: i,
});
} }
} }
} }
} }