summaryrefslogtreecommitdiff
path: root/src/simulation/senses.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-11 14:14:30 -0600
committersanine <sanine.not@pm.me>2023-11-11 14:14:30 -0600
commit8323707d3a2945f8fbd4d4e925a04d1eb6f0a3b7 (patch)
treea78c0957342566e93f9e8045fe0d22fd45818e71 /src/simulation/senses.js
parent78f2f5f4b1ccd58bbdef0d5e5d2dd026ac4ad668 (diff)
prevent movement when frozen and allow seeing past the lattice edge
Diffstat (limited to 'src/simulation/senses.js')
-rw-r--r--src/simulation/senses.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/simulation/senses.js b/src/simulation/senses.js
index d3e7c1e..9cc6c41 100644
--- a/src/simulation/senses.js
+++ b/src/simulation/senses.js
@@ -99,8 +99,9 @@ function vision_idx_to_world_pos(world, agent, idx) {
function see_cell(world, x, y) {
const team = 0;
const orientation = 0;
- if (!world.lattice[y][x]) {
- throw new Error(`${x}, ${y}`);
+ if (!world.lattice[y] || !world.lattice[y][x]) {
+ // beyond the map edge
+ return [ 0, 0, 0 ];
}
const type = {
active: -0.8,