separating itentions from upate
This commit is contained in:
1 parent
6708bf5be6
commit
cff7acdf64
2 files changed
+108
-22
No files matched your search
@@ -0,0 +1,71 @@
|
||||
[33mcommit 6708bf5be66910315c0081ca08fe1d64ef320e97[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mdev-world[m[33m)[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Sat May 30 14:14:22 2026 +0300
|
||||
|
||||
debug fn
|
||||
|
||||
[33mcommit 7cb55a9485b9e0c9a352dc15ee0cb3e77fca7c77[m[33m ([m[1;31morigin/dev-world[m[33m)[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Sat May 30 13:45:13 2026 +0300
|
||||
|
||||
actual world merge
|
||||
|
||||
[33mcommit c6b1b6857230bc4a29c4bf8ad827447b8261ab43[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Tue May 26 12:28:00 2026 +0300
|
||||
|
||||
intention is dote
|
||||
|
||||
[33mcommit 580894ed0a6fafe5d0b6c8b2364c81fc9b2eeaf3[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Fri May 22 12:37:41 2026 +0300
|
||||
|
||||
m_container: is done
|
||||
|
||||
[33mcommit 25af75b381fa022dd7b89c3c31fcef53c085904f[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Fri May 15 17:33:20 2026 +0300
|
||||
|
||||
refactor add_agent
|
||||
|
||||
[33mcommit f9842f635b1cb88e40b6f0415d5844e4390d5988[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Fri May 15 16:06:03 2026 +0300
|
||||
|
||||
add fn add_agent(), temporary mutable access privileges in Word
|
||||
|
||||
[33mcommit 63f2ba31d0445c9a47e01e24944d327c28091284[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Fri May 15 14:16:14 2026 +0300
|
||||
|
||||
agent staruct, TorusGrid derive Clone
|
||||
|
||||
[33mcommit 23591876282ed1b189ae37df1a873f2f30d5d6aa[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Thu May 14 14:50:48 2026 +0300
|
||||
|
||||
fix: add pub to TorusGrid
|
||||
|
||||
[33mcommit 1bca11eb4cec723ee296d3e702b83aec875f35f0[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Thu May 14 13:25:39 2026 +0300
|
||||
|
||||
TorusGrid: был завершон
|
||||
|
||||
[33mcommit 7067e3985c079fde0533aa8c170b98c95907d5b2[m[33m ([m[1;31morigin/vova-rs[m[33m, [m[1;31morigin/dev[m[33m, [m[1;32mdev[m[33m)[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Mon May 11 16:15:42 2026 +0300
|
||||
|
||||
hello
|
||||
|
||||
[33mcommit b6f74c160c8559648edd74c31e5edd1189377173[m[33m ([m[1;31morigin/main[m[33m, [m[1;31morigin/HEAD[m[33m, [m[1;32mmain[m[33m)[m
|
||||
Author: Vova_rs <kolesnik2019v.s@gmail.com>
|
||||
Date: Mon May 11 15:30:33 2026 +0300
|
||||
|
||||
caro init & gitignire set
|
||||
|
||||
[33mcommit 226ef5838b075f284aeb41d137ecfadbb476de2b[m
|
||||
Author: vova-rs <1+vova-rs@noreply.localhost>
|
||||
Date: Mon May 11 14:23:13 2026 +0200
|
||||
|
||||
Initial commit
|
||||
+37
-22
@@ -52,10 +52,7 @@ impl World {
|
||||
pub fn get_a_grid(&self) -> &TorusGrid<Option<usize>> {
|
||||
&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());
|
||||
|
||||
pub fn locl_itention(&self) -> Vec<LinkIntention<LocalItentoin>> {
|
||||
let mut local_it: Vec<LinkIntention<LocalItentoin>> = Vec::new();
|
||||
|
||||
for i in 0..self.agents.len() {
|
||||
@@ -63,14 +60,45 @@ impl World {
|
||||
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,
|
||||
lin: i,
|
||||
});
|
||||
local_it.push(LinkIntention {
|
||||
it: LocalItentoin::SwapCell(ag.get_pos()),
|
||||
lin: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
local_it
|
||||
}
|
||||
pub fn grid_itention(&self) -> TorusGrid<SmallVec<[LinkIntention<Intention>; 4]>> {
|
||||
let mut grid_it: TorusGrid<SmallVec<[LinkIntention<Intention>; 4]>> =
|
||||
TorusGrid::new(SmallVec::new(), self.size.clone());
|
||||
|
||||
for i in 0..self.agents.len() {
|
||||
if let Some(ag) = self.agents.get(i) {
|
||||
let pos = ag.get_pos();
|
||||
let mut p = grid_it.get_mut_wrap(pos);
|
||||
p.push(LinkIntention {
|
||||
it: Intention::StakedOut,
|
||||
lin: i,
|
||||
});
|
||||
let mv = ag.wolk_a();
|
||||
p = grid_it.get_mut_wrap(mv);
|
||||
p.push(LinkIntention {
|
||||
it: Intention::MoveTo,
|
||||
lin: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
grid_it
|
||||
}
|
||||
pub fn update(&mut self) {
|
||||
|
||||
|
||||
let mut local_it = self.locl_itention();
|
||||
|
||||
for i in 0..local_it.len() {
|
||||
match local_it[i].it {
|
||||
LocalItentoin::Rotate(r) => {
|
||||
@@ -86,25 +114,12 @@ impl World {
|
||||
}
|
||||
}
|
||||
}
|
||||
for i in 0..self.agents.len() {
|
||||
if let Some(ag) = self.agents.get(i) {
|
||||
let pos = ag.get_pos();
|
||||
let mut p = plane_of_intentions.get_mut_wrap(pos);
|
||||
p.push(LinkIntention {
|
||||
it: Intention::StakedOut,
|
||||
lin: i,
|
||||
});
|
||||
let mv = ag.wolk_a();
|
||||
p = plane_of_intentions.get_mut_wrap(mv);
|
||||
p.push(LinkIntention {
|
||||
it: Intention::MoveTo,
|
||||
lin: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mut grid_it = self.grid_itention();
|
||||
|
||||
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));
|
||||
let cell = grid_it.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();
|
||||
|
||||
Reference in new issue
Block a user