summaryrefslogtreecommitdiff
path: root/src/simulation/actions.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-10 20:48:53 -0600
committersanine <sanine.not@pm.me>2023-11-10 20:48:53 -0600
commit3b148775e5cf69882fe2503e144777b9ffd166db (patch)
tree28634a561454d31f1858c83caacda57aa4747fc4 /src/simulation/actions.js
parente7eb6a78e165c2103323baa9bd6cbdaf7444c17d (diff)
add pretend_frozen action
Diffstat (limited to 'src/simulation/actions.js')
-rw-r--r--src/simulation/actions.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js
index dd7c4e6..e389518 100644
--- a/src/simulation/actions.js
+++ b/src/simulation/actions.js
@@ -100,7 +100,7 @@ const place = {
const trigger = {
size: 1,
propose: (world, agent, head) => {
- if (head[0] < threshold) { return []; }
+ 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];
@@ -116,7 +116,28 @@ const trigger = {
};
+const pretend_frozen = {
+ size: 1,
+ propose: (world, agent, head) => {
+ if (head[0] < threshold) { return [{
+ agent_changes: [{
+ agent_id: agent.id,
+ flags: { pretend_frozen: false },
+ }],
+ }]; }
+ else {
+ return [{
+ agent_changes: [{
+ agent_id: agent.id,
+ flags: { pretend_frozen: true },
+ }]
+ }];
+ }
+ },
+};
+
+
export const actions = [
move_forward, move_backward, turn_left, turn_right,
- place, trigger,
+ place, trigger, pretend_frozen,
];