diff options
author | sanine <sanine.not@pm.me> | 2023-11-08 00:47:06 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-08 00:47:06 -0600 |
commit | f78493e192daf4639b91352909e4029b9970fcdb (patch) | |
tree | 5b43952cc5da05ffcc942d079f0c3b60674060be /src/world/sense.js | |
parent | 3ae8f476f3865982ca69d0e39b05b5aa8ec43694 (diff) |
implement basic sensing & refactor world/cells -> lattice
Diffstat (limited to 'src/world/sense.js')
-rw-r--r-- | src/world/sense.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/world/sense.js b/src/world/sense.js new file mode 100644 index 0000000..47329b7 --- /dev/null +++ b/src/world/sense.js @@ -0,0 +1,17 @@ +'use strict'; + +/* sense structure: + * { + * size: number + * read: function(lattice, agent) -> number[size] + * } + */ + + +export function sense_read(lattice, agent, sense) { + const result = sense.read(lattice, agent); + if (result.length !== sense.size) { + throw new Error(`Expected result of size ${sense.size}, but got ${result.length} instead.`); + } + return sense.read(lattice, agent); +} |