add local itention for agent
This commit is contained in:
1 parent
c6b1b68572
commit
d4cfb25c8d
2 files changed
+11
-7
No files matched your search
@@ -2,18 +2,16 @@
|
||||
// use super::{MagicContainer, MCError};
|
||||
// use super::TorusGrid;
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Intention {
|
||||
MoveTo,
|
||||
StakedOut,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum LocalItentoin {
|
||||
Rotate(i8),
|
||||
SwapCell,
|
||||
SwapCell((i32, i32)),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
+10
-4
@@ -53,17 +53,23 @@ impl World {
|
||||
&self.a_grid
|
||||
}
|
||||
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();
|
||||
|
||||
for i in 0..self.agents.len() {
|
||||
if let Some(ag) = self.agents.get(i) {
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user