summaryrefslogtreecommitdiff
path: root/src/simulation/actions.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-10 21:10:46 -0600
committersanine <sanine.not@pm.me>2023-11-10 21:10:46 -0600
commit8252de1deb1a677a71108f6c5f8705d7c04a63fe (patch)
treee533d310788a98aa212ccd747b842454445e16a9 /src/simulation/actions.js
parent3b148775e5cf69882fe2503e144777b9ffd166db (diff)
implement unfreeze action
Diffstat (limited to 'src/simulation/actions.js')
-rw-r--r--src/simulation/actions.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js
index e389518..62a8395 100644
--- a/src/simulation/actions.js
+++ b/src/simulation/actions.js
@@ -137,7 +137,29 @@ const pretend_frozen = {
};
+const unfreeze = {
+ size: 1,
+ propose: (world, agent, head) => {
+ if (head[0] < threshold) { return []; }
+ else {
+ const dx = { n: 0, e: 1, s: 0, w: -1 }[agent.flags.orientation];
+ const dy = { n: -1, e: 0, s: 1, w: 0 }[agent.flags.orientation];
+ const target = world.agents.filter(
+ a => a.x === agent.x+dx && a.y === agent.y+dy
+ )[0];
+ if (target === undefined) { return []; }
+ return [
+ { agent_changes: [{
+ agent_id: target.id,
+ flags: { frozen: false, emit: [0, 1, 0, 0, 0, 0, 0, 0] },
+ }]}
+ ];
+ }
+ },
+};
+
+
export const actions = [
move_forward, move_backward, turn_left, turn_right,
- place, trigger, pretend_frozen,
+ place, trigger, pretend_frozen, unfreeze,
];