diff options
Diffstat (limited to 'src/simulation/validity.js')
-rw-r--r-- | src/simulation/validity.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/simulation/validity.js b/src/simulation/validity.js new file mode 100644 index 0000000..de4acd1 --- /dev/null +++ b/src/simulation/validity.js @@ -0,0 +1,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, + ), +]; |