diff options
Diffstat (limited to 'src/simulation/actions.js')
-rw-r--r-- | src/simulation/actions.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js new file mode 100644 index 0000000..40545c5 --- /dev/null +++ b/src/simulation/actions.js @@ -0,0 +1,28 @@ +'use strict'; + +const threshold = 0.5; + + +const move_forward = { + size: 1, + propose: (agent, head) => { + if (head[0] > threshold) { + 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]; + return [{ + agent_changes: [{ + agent_id: agent.id, + x: agent.x + dx, + y: agent.y + dy, + }], + }]; + } else { + return []; + } + }, +}; + + +export const actions = [ + move_forward, +]; |