From 7825b92ce3be95a0ce1dfea9388adbaadce83b1f Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 12 Nov 2023 15:18:29 -0600 Subject: fix bugs --- src/world/agent.js | 2 +- src/world/proposal.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/world') diff --git a/src/world/agent.js b/src/world/agent.js index dbfdf5d..2be7420 100644 --- a/src/world/agent.js +++ b/src/world/agent.js @@ -7,7 +7,7 @@ import { proposal_merge } from './proposal.js'; export function agent_decide(world, agent, senses, actions) { const inputs = senses.map(s => sense_read(world, agent, s)).flat(); const [result, state] = agent.net.compute(inputs, agent.state); - console.log(agent, result); + console.log(result, state); const new_agent = { ...agent, state }; const [proposals, _] = actions.reduce( diff --git a/src/world/proposal.js b/src/world/proposal.js index 0969540..8baca06 100644 --- a/src/world/proposal.js +++ b/src/world/proposal.js @@ -57,6 +57,7 @@ import { pairs, deepEqual } from '../util.js'; // check that two flags objects are compatible // flags are considered compatible if they do not have any common keys with different values function flags_compatible(a, b) { + if (a === undefined || b === undefined) { return true; } const keys = [...new Set(Object.keys(a).concat(Object.keys(b)))]; return keys.reduce( (acc, key) => { @@ -80,7 +81,7 @@ function lattice_change_conflict(a, b) { if ( a.x === b.x && a.y === b.y && - (a.to != b.to || !flags_compatible(a.flags || {}, b.flags || {})) + (a.to != b.to || !flags_compatible((a.flags || {}), (b.flags || {}))) ) { // conflict! return [true, false]; -- cgit v1.2.1