0.3.0
Two big new introductions to the Flocc family are:
Lisp-like Rules
A new constructor, Rule
, can be used in place of a function in agent.addRule(rule)
. So far these Rule
s are less efficient than using functions directly, but have a lot of promise in giving the rules agents follow a tangible data structure, rather than interpreted from function syntax. Documentation to come.
Ex.
const steps = [
['local', 'x', 10],
['local', 'y', 20],
[
'set',
'pos',
['vector', ['local', 'x'], ['local', 'y']
]
];
const rule = new Rule(steps);
agent.addRule(rule);
Equivalent to:
function rule(agent) {
const x = 10;
const y = 20;
agent.set('pos', new Vector(x, y));
}
agent.addRule(rule);
Histogram Renderer
Like the LineChartRenderer
, a Histogram
visualizes aggregate data, by sorting agent data into 'buckets' and depicting the relative size (# of agents) in each bucket (say, 0-10 vs. 10-20 vs. 20-30).
Ex.
const histogram = new Histogram(environment, {
buckets: 6,
min: 0,
max: 90
});
histogram.mount('#histogram');
histogram.metric('age'); // key of agent data to bucket