Skip to content

Releases: scottpdo/flocc

0.2.4

09 Oct 20:22
58baa64
Compare
Choose a tag to compare

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, and rgba 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

08 Oct 13:40
e473d59
Compare
Choose a tag to compare

New CanvasRenderer options:

  • Set a background color
  • Set scale
  • Set origin (coordinates of upper-left)

Ex.

const renderer = new CanvasRenderer(environment, {
  background: 'green',
  scale: 2,
  origin: {
    x: 100,
    y: 75
  }
});

0.2.2

25 Jun 00:36
e958d59
Compare
Choose a tag to compare

Adds a .rotateZ method to vectors. Will probably extend this to allow rotations about X and Y axes as well.

0.2.1

20 Jun 15:00
11489f7
Compare
Choose a tag to compare

Adds two new Network methods:

  • .clear(): removes all Agents from a Network
  • .addFromEnvironment(env): adds all agents from an Environment to the Network

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

11 Jun 18:47
707dbc3
Compare
Choose a tag to compare

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, LineChartRenderers 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 and utils.min (maximum and minimum values of an array, basically just shells of Math.max and Math.min)
  • utils.median

0.1.5

10 Jun 18:34
Compare
Choose a tag to compare

Minor security upgrade to address development package vulnerabilities.

0.1.4

15 May 15:23
481494d
Compare
Choose a tag to compare
  • Add time key to Environment (auto-increments with every tick)
  • Add neighbors method to GridEnvironment (options for Moore or von Neumann neighborhood)
    • Build out tests for GridEnvironment
  • Add random util function
  • Add zfill util function

0.1.3

26 Mar 15:01
679c832
Compare
Choose a tag to compare

Adds Network helper structure (i.e. undirected graph).

  • New API for adding helpers to Environments: Environment.use(network); (instance of Network or, in the future, some other helper)
  • CanvasRenderer will always draw connections between Agents
  • New option for CanvasRenderers: { autoPosition: boolean } (if true, will automatically assign x/y values to Agents and position them in an ellipse

0.1.2

22 Mar 20:14
08b9e7b
Compare
Choose a tag to compare

Environments can now store arbitrary data, just like Agents (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.

0.1.1

02 Feb 19:52
08b9e7b
Compare
Choose a tag to compare

CanvasRenderers and ASCIIRenderers both now clear their container's innerHTML before adding the <canvas> or <pre> element for rendering.