diff options
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); +} |