Changing the neighborhood
The following standard neighborhoods are provided:
- Square neighborhoods of any size.
- Circular neighborhoods of any radius.
Some of these have special names and are predefined for you. A square
neighborhood containing eight neighbors (a 3x3 square with the agent located
at the center) is a Moore8Neighborhood and a square neighborhood
containing twenty-four neighbors (a 5x5 square with the agent located at the
center) is a Moore24Neighborhood. You can switch between these
by entering
SetDefaultNeighborhood( Moore8Neighborhood );
or
SetDefaultNeighborhood( Moore24Neighborhood );
Because you are changing the default neighborhood, you have to create a new
model before the change takes affect.
Another common neighborhood consists of the four neighbors at the cardinal
compass points: north, south, west, and east. This neighborhood is known
as the VonNeumannNeighborhood and can be set as the default by entering
SetDefaultNeighborhood( VonNeumannNeighborhood );
Using arbitrary square and round neighborhoods
An arbitrary square neighborhood is created by choosing a "radius". A
square neighborhood of radius R consists of the (2R+1) x (2R+1) square centered
on the agent, so the Moore 8 neighborhood has radius 1 and the Moore 24 neighborhood
has radius 2. A square neighborhood of radius R is made the default
by entering
SetDefaultNeighborhood( SquareNeighborhood(R) );
Round neighborhoods of a radius R consist of all the cells whose centers
fall with R units from the center of the agent's cell. For small R,
the neighborhood will not look very circular. You set a round neighborhood
of radius R to be the default by entering
SetDefaultNeighborhood( RoundNeighborhood(R) );