diff options
author | sanine <sanine.not@pm.me> | 2023-11-10 19:51:02 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-10 19:51:02 -0600 |
commit | 984f07a24d3d377c13358fc5533c0eda383858f5 (patch) | |
tree | f5031a2abc9b5382c3c1f585481a82a4da7553da /src/simulation/actions.js | |
parent | 57172b8c3c851497b55b5d4c90ddb0cb5f9b202c (diff) |
refactor: actions take an additional world parameter
Diffstat (limited to 'src/simulation/actions.js')
-rw-r--r-- | src/simulation/actions.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js index aaaf1d8..0f1a767 100644 --- a/src/simulation/actions.js +++ b/src/simulation/actions.js @@ -5,7 +5,7 @@ const threshold = 0.5; const move_forward = { size: 1, - propose: (agent, head) => { + propose: (world, 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]; @@ -24,7 +24,7 @@ const move_forward = { const move_backward = { size: 1, - propose: (agent, head) => { + propose: (world, 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]; @@ -44,7 +44,7 @@ const move_backward = { const turn_left = { size: 1, - propose: (agent, head) => { + propose: (world, agent, head) => { if (head[0] > threshold) { const orientation = { n: 'w', e: 'n', s: 'e', w: 's' }[agent.flags.orientation]; return [{ @@ -62,7 +62,7 @@ const turn_left = { const turn_right = { size: 1, - propose: (agent, head) => { + propose: (world, agent, head) => { if (head[0] > threshold) { const orientation = { n: 'e', e: 's', s: 'w', w: 'n' }[agent.flags.orientation]; return [{ |