summaryrefslogtreecommitdiff
path: root/src/simulation/actions.js
blob: 40545c587f458f52596e38d59d516c43feaac72d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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,
];