Opinions along connections
Forty points on a ring pull their opinions towards those of the points they are connected to, unless those opinions are too far from their own.
opinion at one end of the scaleopinion at the other end
A NetworkManager holds the connections: who is linked to whom, with a weight and a type. At the start each point is connected to the two points either side of it on the ring, and some connections are rewired to a point anywhere on the ring. The share rewired is the shortcuts setting, which applies when you press Reset.
Each step a point reads the opinions of the points it is connected to and moves halfway towards the average of those within the tolerance of its own. Opinions that are far apart do not pull on each other, so with a low tolerance the ring settles into several groups; with a high one, into a single group.
The readout counts the groups of opinion and asks the network for its size and its connected parts (getNetworkAnalysis). Colour is the opinion itself, one end of the scale to the other.
Classes used
NetworkManager (addConnection, getConnections, getNetworkAnalysis), ConnectionType, BaseAgent, RandomScheduler.
Source
This is example.js, the file this page runs.
Loading the source…