diff options
Diffstat (limited to 'src/world/world.js')
-rw-r--r-- | src/world/world.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/world/world.js b/src/world/world.js index e1d984d..e1ba0cf 100644 --- a/src/world/world.js +++ b/src/world/world.js @@ -3,6 +3,17 @@ import { agent_decide, agent_apply } from './agent.js'; import { proposal_merge } from './proposal.js'; +// world structure: +// { +// lattice +// lattice_rules: object +// agents: agent[] +// senses: sense[] +// actions: action[] +// validity: (function(proposal) => bool)[] +// } + + export function world_update(world, postprocess=[]) { const lattice_props = lattice_update(world.lattice, world.lattice_rules); const intermediate_lattice = lattice_apply(world.lattice, lattice_props); @@ -19,7 +30,10 @@ export function world_update(world, postprocess=[]) { .reduce((acc, prop) => proposal_merge(acc, prop), []) .filter(prop => lattice_valid(intermediate_lattice, prop)) - const lattice = lattice_apply(intermediate_lattice, agent_props); + const lattice = lattice_apply(intermediate_lattice, world.validity.reduce( + (acc, rule) => acc.filter(rule), + agent_props + )); const agents = intermediate_agents.map(a => agent_apply(a, agent_props)); const new_world = {...world, lattice, agents}; |