summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-12 15:18:29 -0600
committersanine <sanine.not@pm.me>2023-11-12 15:18:29 -0600
commit7825b92ce3be95a0ce1dfea9388adbaadce83b1f (patch)
treeeb1e38561e3aba4b890e666e04d46e4de499658e /src/simulation
parent95fd952b6d4c496efc0e6236ba2acfcbbeee8ed9 (diff)
fix bugs
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/actions.js6
-rw-r--r--src/simulation/senses.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/simulation/actions.js b/src/simulation/actions.js
index 3b3e942..ad08572 100644
--- a/src/simulation/actions.js
+++ b/src/simulation/actions.js
@@ -9,6 +9,7 @@ const move_forward = {
if (agent.flags.frozen === true) { return []; }
if (head[0] > threshold) {
console.log('move forward');
+ console.log(agent.id, agent.x, agent.y);
const dx = { n: 0, e: 1, s: 0, w: -1 }[agent.flags.orientation];
const dy = { n: -1, e: 0, s: 1, w: 0 }[agent.flags.orientation];
return [{
@@ -30,6 +31,7 @@ const move_backward = {
propose: (world, agent, head) => {
if (agent.flags.frozen === true) { return []; }
if (head[0] > threshold) {
+ console.log('move backward');
const dx = { n: 0, e: 1, s: 0, w: -1 }[agent.flags.orientation];
const dy = { n: -1, e: 0, s: 1, w: 0 }[agent.flags.orientation];
return [{
@@ -51,6 +53,7 @@ const turn_left = {
propose: (world, agent, head) => {
if (agent.flags.frozen === true) { return []; }
if (head[0] > threshold) {
+ console.log('turn left');
const orientation = { n: 'w', e: 'n', s: 'e', w: 's' }[agent.flags.orientation];
return [{
agent_changes: [{
@@ -70,6 +73,7 @@ const turn_right = {
propose: (world, agent, head) => {
if (agent.flags.frozen === true) { return []; }
if (head[0] > threshold) {
+ console.log('turn right');
const orientation = { n: 'e', e: 's', s: 'w', w: 'n' }[agent.flags.orientation];
return [{
agent_changes: [{
@@ -250,7 +254,7 @@ const speak = {
export const actions = [
- move_forward, move_backward, turn_left, turn_right,
+ move_forward, /*move_backward, */turn_left, turn_right,
place, trigger, pretend_frozen, unfreeze, take_flag, drop_flag,
speak,
];
diff --git a/src/simulation/senses.js b/src/simulation/senses.js
index 9d50a83..970f86b 100644
--- a/src/simulation/senses.js
+++ b/src/simulation/senses.js
@@ -150,7 +150,7 @@ function see_agent(viewer, agent) {
const see = {
- size: VIS_WIDTH * VIS_HEIGHT,
+ size: 3*VIS_WIDTH * VIS_HEIGHT,
read: (world, agent) => {
const indices = [...Array(VIS_WIDTH*VIS_HEIGHT).keys()]
const vision = indices
@@ -171,12 +171,12 @@ const see = {
},
vision
);
- return result;
+ return result.flat();
},
};
export const senses = [
- frozen, hear, see,
+ frozen, hear, see, { size: 1, read: () => [1] },
];