Playground

program.js is the aggregate program, the same code that goes on a device. config.js describes the simulated network: nodes, layout, sensors. Every change restarts the network. To device ↗ uploads the program to a Puck.js or an ESP32.

Quick reference

Operators: xc, retsend, nbr, rep, share, branch, align, aggregate, id(), sense(name) (in the simulator source, obstacle, x, y and those from config.js), nbrSense('range').

Display: a node shows its value, coloured by it; return { label, value } to show the label and colour by the value.

Fields: .self, .map((v, id) => ...), .zip(other, (a, b) => ...), .reduce(f, initial), .min(), .max(), .sum(), .at(id). Reductions skip the device itself.

Library: hopsTo, distanceTo, broadcast, collect, collectSum, isLeader, networkMax, networkMin, neighbourCount, rounds, countdown, minId.

config.js: nodes, layout, range, sources, obstacles, period, sensors. As on a radio: loss, skip, ttl, and target: 'ble' for Bluetooth messages (hover a node to see them).

Aggregate code under if, ?:, && or || needs branch(cond, () => ..., () => ...): the line under the editor warns when it is missing.

Everything in detail: Reference.