Interactive Swarm Space

Spaces, Shapes and Structures

Within ISO, "Space" has a very distinct meaning and purpose. Spaces allow the interaction of agents with each other by allowing them to see each other. However it would be misleading to think of spaces as simply a grid where each agent has its position - think of a Space as a collection of lists that contain each agents closest neigbors. By "closest" we would immediately think of "spacial distance" (Agent parameter "position"), which is in fact only one possible proximity feature amongst agents. You could also have lists in your Space that contain all agent neigbors that move at a similar velocity or have a similar mass. In short ANY kind of parameter can be used for neighborhood lists. However, not all parameters are subject to the same rate of change! The parameter "mass" for example is normally fairly constant while "position" is likely to change every time step. This allows for optimized calculation processes that determines who will be in an agent's neighborhood list and who won't. This page will introduce you to the neigbhorhood computation algorithms used by ISO and will show you when and how to use each one of them.

Table of content:

How to set up a space
Space Algorithms
Shape Types

How to setup a space new space::Space("PARAMETER_NAME",
                                SPACE_ALGORITHM_OBJECT(NUM_DIMENSIONS) ) );

For example: new space::Space("agent_position", new space::ANNAlg(3) ) );

This example will create the most common of Spaces, the "position"-based space. As a space algorithm we have chosen the ANN algorithm, which is best suited for rapidly changing lists that don't have to be 100% exact. This is the best choice for our "position"-based space, because our agents will often switch neibhors (one guy flying by closely, another being torn away by a different group of agents, ...).

Space Algorithms

Common Types

Name Performance Precision Call Syntax
PermanentNeighborsextremely fast -
new space::PermanentNeighborsAlg(3)
NTree slow precise
new space::NTreeAlg(3)
KDTree slow precise
new space::KDTreeAlg(3)
ANN fast unprecise
new space::ANNAlg(3)

You might have noticed that NTree and KDTree have the same attributes, which in reality they do in fact (from the viewpoint of the user). It's probably best to simply try for yourself to see which one of these is easier on your processor for a given simulation. Also note, eventhough ANN is depicted as fast, with rising agent count and rising list volatility (rate of change), ANN will also become very slow. It can generally be said about ISOFlock, that neighborhood computation is clearly the performance bottle neck, which is in fact true for all physics simulations.

Specialized Types

Name PerformancePrecision Call Synthax
Grid very fast (see below)
new space::GridAlg(3)
RTreeAlg fast (see below)
new space::RTreeAlg(3)

These two algorithms cannot be used for simple agent-to-agent neighborhood calculation, instead they have two additional purposes.

GridAlg will let you assign values to locations in space. Agents will later read these values while moving through this spacific cell (or field, if it's a 2-dimensional grid). This can be used to simulate for example nutrition in the ground - which is consumed by the agents, affecting their health and/or procreation. We have also used Grids in interactive dance installations to measure the intensity of motion in a specific image segment and create appropriate agent responses to that local intensity - e.g. being attracted or repulsed by it. Likewise, GridAlg can be the answer for many of your interaction design troubles. Try it out :).

RTreeAlg is a agent-to-shape neighborhood calculation algorithm. Shapes will be explained further down. For now it's only important to know that by using an RTree, you will be able to get the minimal distance to the shape's bounding box.

Shape Types

shape types are concerned with calculating their own bounding box. things in space that have an spatial extension

SplineShape: needed by shapespace (part of geom framework). 1 uninterupted spline.

SplineGroupShape: n splines (e.g. for fonts) with common bounding box

MeshShape: polygon object (3-dimensional!)