import { sense_read } from './sense.js'; test("basic sense works", () => { const flag_sense = { size: 1, read: (lattice, agent) => { const {x, y} = agent; return [ 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]); }); test("senses throw if the size is incorrect", () => { const flag_sense = { size: 2, read: (lattice, agent) => { const {x, y} = agent; return [ 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(); });