relese global intention

This commit is contained in:
lemon-cat committed 2026-05-27 12:48:31 +03:00
1 parent 60bd764bcf
commit a02b40c043
2 files changed
+24 -10

No files matched your search

+5 -5
View File
@@ -2,19 +2,19 @@
// use super::{MagicContainer, MCError}; // use super::{MagicContainer, MCError};
// use super::TorusGrid; // use super::TorusGrid;
#[derive(Clone)] #[derive(PartialEq, Clone)]
pub enum Intention { pub enum Intention {
MoveTo((i32, i32)), MoveTo,
StakedOut((i32, i32)), StakedOut,
} }
#[derive(Clone)] #[derive(PartialEq, Clone)]
pub enum LocalItentoin { pub enum LocalItentoin {
Rotate(i8), Rotate(i8),
SwapCell((i32, i32)), SwapCell((i32, i32)),
} }
#[derive(Clone)] #[derive(PartialEq, Clone)]
pub struct LinkIntention<T: Clone> { pub struct LinkIntention<T: Clone> {
pub it: T, pub it: T,
pub lin: usize, pub lin: usize,
+19 -5
View File
@@ -86,18 +86,32 @@ impl World {
} }
} }
} }
let mut global_it: Vec<LinkIntention<Intention>> = 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) {
global_it.push(LinkIntention { let pos = ag.get_pos();
it: Intention::MoveTo(ag.wolk_a()), let mut p = plane_of_intentions.get_mut_wrap(pos);
p.push(LinkIntention {
it: Intention::StakedOut,
lin: i, lin: i,
}); });
global_it.push(LinkIntention { let mv = ag.wolk_a();
it: Intention::StakedOut(ag.get_pos()), p = plane_of_intentions.get_mut_wrap(mv);
p.push(LinkIntention {
it: Intention::MoveTo,
lin: i, lin: i,
}); });
} }
} }
for i in 0..self.size.0 {
for j in 0..self.size.1 {
let cell = plane_of_intentions.get_mut_wrap((i as i32, j as i32));
if cell.len() == 1 {
if cell[0].it == Intention::MoveTo {
let ag = self.agents.get_mut(cell[0].lin).unwrap();
ag.move_to(ag.wolk_a());
}
}
}
}
} }
} }