Releases: scottpdo/flocc
0.2.4
Enhancements to Agents, Vectors, and a new utility function.
Agent
agent.set(key, value)
now accepts a function as its value. Whenever this piece of data is referenced, it calls the function behind the scenes. This allows for agent data to reference other pieces of internal or external data (CAUTION: functions-as-values should probably not have side effects). For example, if an agent has x and y values, rather than needing to create a Vector outside of the agent, a new key-value pair can be added that returns the Vector automatically. See below:
const agent = new Agent();
agent.set('x', 5);
agent.set('y', 2);
agent.set('position', () => new Vector(agent.get('x'), agent.get('y'));
agent.get('position'); // returns a Vector with x and y values corresponding to those of the agent
Vector
- Adds
xy
,xz
,yz
,xyz
,rgb
, andrgba
getters that return arrays of the corresponding indices. - Add a method to take the dot product of one Vector with another (
v1.dot(v2)
). - Add a method to linearly interpolate between one Vector and another (returns a new Vector; does not mutate the original Vector) (
v1.lerp(v2, 0.3)
.
New utility function: lerp
- Linearly interpolate between two numerical values (used in the above Vector method).
0.2.3
0.2.2
0.2.1
Adds two new Network
methods:
.clear()
: removes allAgent
s from aNetwork
.addFromEnvironment(env)
: adds all agents from anEnvironment
to theNetwork
Update some JSDoc notes for Environment
Add tests for the above Network
methods as well as new stats functions (min
, max
, median
)
0.2.0
Flocc v0.2.0 introduces a meta-level renderer: the LineChartRenderer
class. Environments can now have multiple renderers, so the environment and agents themselves can be rendered alongside a visualization of aggregate agent statistics (in the future, this will include other types of visualizations). Right now, LineChartRenderer
s include:
- Ability to visualize one or multiple metrics. A metric corresponds to a
key/value
pair agent data, and has access to all the values for agents that have that key. - Ability to customize the metric function — whether it should show (ex.) the mean of values, the median, the sum, a custom function, etc. (metric functions must map an array of numbers to a single number).
- Automatic "smart" vertical guides based on the y-range of the chart (i.e. a chart visualizing values between 42 and 513 would have guides at 100, 200, 300, 400, and 500).
There are also a few new utility functions:
utils.max
andutils.min
(maximum and minimum values of an array, basically just shells ofMath.max
andMath.min
)utils.median
0.1.5
0.1.4
0.1.3
Adds Network
helper structure (i.e. undirected graph).
- New API for adding helpers to
Environment
s:Environment.use(network);
(instance ofNetwork
or, in the future, some other helper) CanvasRenderer
will always draw connections betweenAgent
s- New option for
CanvasRenderer
s:{ autoPosition: boolean }
(iftrue
, will automatically assignx
/y
values toAgent
s and position them in an ellipse
0.1.2
Environment
s can now store arbitrary data, just like Agent
s (useful for keeping track of 'global' variables).
Adds a new DataObj
interface, which both Agent
and Environment
implement:
data: Data;
set(name: string | Data, value?: any): void;
get(name: string): any;
getData(): Data;
Also adds a set of tests for Environment
.