summaryrefslogtreecommitdiff
path: root/src/simulation/validity.js
blob: de4acd1bcdf7454268558ff5258725eba5e8ba68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export const validity = [
  // prevent agents from moving onto immutables
  (world, proposal) => (proposal.agent_changes || []).reduce(
    (acc, change) => {
      const {x, y} = change;
      if (x !== undefined && y !== undefined && world.lattice[y][x].type === 'immutable') {
        return false;
      } else {
        return acc;
      }
    },
    true,
  ),
];