summaryrefslogtreecommitdiff
path: root/src/world/sense.test.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-10 11:24:56 -0600
committersanine <sanine.not@pm.me>2023-11-10 11:24:56 -0600
commit428062dccb362627b4251945632c75d9db8f93f7 (patch)
tree27d50a332414ccd105997827102ff0a59403f58e /src/world/sense.test.js
parent1b92f501c40eded57d66946ff717e49a5362f7c3 (diff)
refactor senses to use world instead of lattice only
Diffstat (limited to 'src/world/sense.test.js')
-rw-r--r--src/world/sense.test.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/world/sense.test.js b/src/world/sense.test.js
index 1ef7bce..27ee2b5 100644
--- a/src/world/sense.test.js
+++ b/src/world/sense.test.js
@@ -4,30 +4,30 @@ import { sense_read } from './sense.js';
test("basic sense works", () => {
const flag_sense = {
size: 1,
- read: (lattice, agent) => {
+ read: (world, agent) => {
const {x, y} = agent;
- return [ lattice[y-1][x].type === 'flag' ? 1.0 : 0.0 ]
+ return [ world.lattice[y-1][x].type === 'flag' ? 1.0 : 0.0 ]
},
};
const lattice = [[ { type: 'flag' } ]];
const agent = { x: 0, y: 1 };
- expect(sense_read(lattice, agent, flag_sense)).toEqual([1.0]);
+ expect(sense_read({lattice}, agent, flag_sense)).toEqual([1.0]);
});
test("senses throw if the size is incorrect", () => {
const flag_sense = {
size: 2,
- read: (lattice, agent) => {
+ read: (world, agent) => {
const {x, y} = agent;
- return [ lattice[y-1][x].type === 'flag' ? 1.0 : 0.0 ]
+ return [ world.lattice[y-1][x].type === 'flag' ? 1.0 : 0.0 ]
},
}
const lattice = [[ { type: 'flag' } ]];
const agent = { x: 0, y: 1 };
- expect(() => sense_read(lattice, agent, flag_sense)).toThrow();
+ expect(() => sense_read({lattice}, agent, flag_sense)).toThrow();
});