diff options
Diffstat (limited to 'src/simulation/actions.js')
-rw-r--r-- | src/simulation/actions.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js index 0f1a767..8a4e8f0 100644 --- a/src/simulation/actions.js +++ b/src/simulation/actions.js @@ -78,8 +78,27 @@ const turn_right = { }; +const place = { + 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]; + return [ + { lattice_changes: [{ + x: agent.x + dx, y: agent.y + dy, + from: 'empty', to: 'mutable', + flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] }, + }]} + ]; + } + }, +}; + + export const actions = [ - move_forward, move_backward, turn_left, turn_right, + move_forward, move_backward, turn_left, turn_right, place, ]; |