summaryrefslogtreecommitdiff
path: root/src/world/sense.js
blob: 9b5c7d40854d283c3e8757d61b807bee521921e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'use strict';

/* sense structure:
 * {
 *   size: number
 *   read: function(lattice, agent) -> number[size]
 * }
 */


export function sense_read(world, agent, sense) {
  const result = sense.read(world, agent);
  if (result.length !== sense.size) {
    throw new Error(`Expected result of size ${sense.size}, but got ${result.length} instead.`);
  }
  return result;
}