summaryrefslogtreecommitdiff
path: root/src/world/agent.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-16 14:50:00 -0600
committersanine <sanine.not@pm.me>2023-11-16 14:50:00 -0600
commitf9fc4d26ec5fca9ee175c8a6fbcdd0fa36f10947 (patch)
treef190e6e465bb563c608a916f41fc8bf686ea2897 /src/world/agent.js
parent7825b92ce3be95a0ce1dfea9388adbaadce83b1f (diff)
clear out js files
Diffstat (limited to 'src/world/agent.js')
-rw-r--r--src/world/agent.js56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/world/agent.js b/src/world/agent.js
deleted file mode 100644
index 2be7420..0000000
--- a/src/world/agent.js
+++ /dev/null
@@ -1,56 +0,0 @@
-'use strict';
-
-import { sense_read } from './sense.js';
-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(result, state);
-
- const new_agent = { ...agent, state };
- const [proposals, _] = actions.reduce(
- ([proposals, result], action) => {
- const head = result.slice(0, action.size);
- const tail = result.slice(action.size);
-
- const props = action
- .propose(world, new_agent, head)
- .reduce(
- (acc, proposal) => proposal_merge(acc, proposal),
- proposals
- );
-
- return [props, tail];
- },
- [[], result]
- );
-
- return [new_agent, proposals];
-}
-
-
-function change_apply(agent, ch) {
- const { x, y, flags } = ch;
- return {
- ...agent,
- x: (x || agent.x), y: (y || agent.y),
- flags: { ...agent.flags, ...flags },
- };
-}
-
-
-export function agent_apply(agent, proposals) {
- return proposals
- .filter(p => p.agent_changes)
- .reduce(
- (acc, p) => p.agent_changes
- .filter(ch => ch.agent_id === agent.id)
- .reduce(
- (acc_, ch) => change_apply(acc_, ch),
- acc
- ),
- agent
- );
-}