Commands

AddEdge (One, Two)
Adds an edge between the agent with index One and the agent with index Two.

bsh% for (i=0; i<14; i++) {
AddEdge (0, (100/13)*i);
}

Before
After


Agent
GetAgent (Index)
Returns the agent at index. This function works for all models except two-dimensional lattices (which require an additional coordinate).

In a one-dimensional lattice, the index increases from 0 at the left to NumberOfAgents-1 at the right.
In small-world networks, the index increases from 0 at 3 o'clock (see above) to NumberOfAgents-1 in clockwise fashion.
In bounded degree networks, the index increases as in small-world networks.
Dynamic networks draw the index over the center of the node.
 
Agent GetAgent (XCoordinate, YCoordinate)
Returns the agent in the two-dimensional lattice at (XCoordinate,YCoordinate). This function only works for two-dimensional lattices.
 
LinkedListExpandedNeighborhood (Agent, Depth)
Get the expanded neighborhood of Agent to Depth. The expanded neighborhood consists of all neighbors, plus neighbors-of-neighbors, plus neighbors-of-neighbors-of-neighbors, where the length of the chain is the depth. An expanded neighborhood of depth 1 is just the original neighborhood of the agent. An expanded neighborhood of depth 2 is the original neighborhood plus all of the neighbors of neighbors.

By definition, any expanded neighborhood of depth greater than 1 contains the original agent.

It is marginally more efficient to get the neighborhood of an agent by calling agent.getNeighborhood() instead of ExpandedNeighborhood(agent,1);

The following code sets all members of the 3-expanded neighborhood (using the Moore 8 neighborhood) of the agent at (50,50) to 5.

bsh% SetStrategies( ExpandedNeighborhood( GetAgent(50,50), 3), 5);

Before After

Collection  ExpandedNeighborhood (Collection, Depth)
Construct the expanded neighborhood of for all agents in Collection and return it as a collection.

When combined with RandomSubset, this allows one to introduce "blocks" of mutants at random locations in the network or lattice. For
example, in a two-dimensional lattice where all individuals use the Moore 8 neighborhood, the following command selects 4 individuals at
random from the population and changes them, plus the squares surrounding them in the lattice, to the strategy Demand 5.

bsh% SetStrategies( ExpandedNeighborhood( RandomSubset(population, 4), 2), 5);
This could also be written (for greater clarity) as:
bsh% subset = RandomSubset(population, 4);
bsh% expanded_subset = ExpandedNeighborhood(subset, 2);
bsh% SetStrategies( expanded_subset, 5 );

Before After


Collection
  RandomSubset (Collection, Size)
Construct a random subset containing size elements from Collection and return this as a collection.

This can be used to introduce a number of "mutations" into the population. For example, suppose we have a 4--6 polymorphism of
divide-the-dollar. Then the following command introduces 3 mutants following Demand 5 into the population:

bsh% SetStrategies( RandomSubset( population, 3 ), 5 );

SaveBitmap (Filename)
Save a bitmapped image of the current display to Filename. The bitmapped image is in PNG format.
bsh% SaveBitmap("/Users/jalex/bitmaps/foo.png");

SetInitialConditions
(Array)
Change the default initial conditions for future new models to that specified by Array. The value of Array[i] is the
relative frequency of strategy i.

The values of Array need not sum to 1, as the sum is normalized before being used. This makes it convenient to specify
frequencies in terms of one strategy being twice as common as another and six times as common as yet another.

The length of array must equal the number of strategies in the current model, otherwise an error occurs.

bsh% double[] array = {0.0, 0.0, 1.0, 0.5, 0.25, 4.0}
bsh% SetInitialConditions(array);

SetStrategy (Agent, Strategy)
Sets the strategy of Agent to strategy.  All strategies are represented by integers between 0 and NumberOfStrategies.
bsh% SetStrategy( GetAgent( 50 ), 5);

SetStrategy
(Collection, Strategy)
Sets the strategy of all agents in collection to strategy. This function is most useful when combined with the functions that automatically generate collections, like Partition, ExpandedNeighborhood, and RandomSubset.

SetStrategies
(Collection, Strategy)
A grammatically correct form of SetStrategy applied to collections.

Collection[]
Partition (Collection, Number)
Partition Collection into number disjoint subsets and return an array of collections, each collection containing the members of one partition.
bsh% p = Partition(population, 3);
bsh% SetStrategies(p[0], 4);
bsh% SetStrategies(p[1], 5);
bsh% SetStrategues(p[2], 6);

Initialization commands for lattice models

FrontierCompetition (LeftStrategy, RightStrategy)
Creates a frontier competition between LeftStrategy and RightStrategy.

bsh% FrontierCompetition( 3, 6 );

FrontierCompetition (LeftStrategy, LeftOtherStrategy, Probability, RightStrategy)
Creates a frontier competition between LeftStrategy and RightStrategy, adding the additional strategy LeftOtherStrategy to the left region with Probability.

bsh% FrontierCompetition(3, 5, 0.25, 6);

FrontierCompetition (LeftStrategy, RightStrategy, RightOtherStrategy, Probability)
As above, but with the additional strategy added to the right region.

bsh% FrontierCompetition(3, 5, 6, 0.25);

FrontierCompetition (LeftStrategy, LeftOtherStrategy, Probability1, RightStrategy, RightOtherStrategy, Probability2)
The combined version of the above. Useful for generating competitions between polymorphic pairs.

bsh% FrontierCompetition(4, 6, 0.2, 3, 7, 0.2);

CenterCompetition(MajorStrategy, MinorStrategy, Diameter)
Creates a competition with MajorStrategy assigned to all agents in the lattice, except for a block of width Diameter in the middle assigned MinorStrategy.

DiagonalCompetition
(MajorStrategy, MinorStrategy)
Creates a competition in a two-dimensional lattice with opposing strategies above and below the main diagonal.