org.graphstream.boids
Class BoidSpecies

java.lang.Object
  extended by org.graphstream.boids.BoidSpecies
All Implemented Interfaces:
Iterable<Boid>

public class BoidSpecies
extends Object
implements Iterable<Boid>

Parameters for each boids species.

Author:
Guilhelm Savin, Antoine Dutot

Nested Class Summary
static class BoidSpecies.Parameter
          Kinds of parameters.
 
Constructor Summary
BoidSpecies(BoidGraph ctx, String name)
          New default species with a random color.
 
Method Summary
 Boid createBoid()
          Create a new boid with an automatic id created using createNewId().
 Boid createBoid(String id)
          Create a new boid.
 String createNewId()
          Create a new unique id specific to this species.
 double getAngleOfView()
          The boid angle of view, [-1..1].
 double getAttractionFactor()
          How much other visible boids attract a boid.
 Color getColor()
          The species main color.
 double getDirectionFactor()
          The importance of the other boids direction "overall" vector.
 double getFearFactor()
          Factor for repulsion on boids of other species.
 double getInertia()
          The inertia is the importance of the boid previous direction in the boid direction.
 double getMaxSpeed()
          Maximum speed bound.
 double getMinSpeed()
          Minimum speed bound.
 String getName()
          Getter for the name of the species.
 int getPopulation()
          Count of boids of this species.
 double getRepulsionFactor()
          All the visible boids repulse the boid.
 double getSpeedFactor()
          The boid speed at each step.
 double getViewZone()
          The distance at which a boid is seen.
 Iterator<Boid> iterator()
           
 void release()
          Unregister this species from the boids graph.
 void set(BoidSpecies.Parameter p, String val)
          Utility function to set parameter from an enum constant and a string value.
 void set(String p, String val)
          Same than set(Parameter, String) but the enum constant is given as a string.
 void setAngleOfView(double aov)
          Set the angle of view for boids of this species.
 void setAttractionFactor(double attractionFactor)
          Change how much other visible boids attract a boid.
 void setColor(Color color)
          Change the species main color.
 void setCount(int count)
          Create boids until population is at least count.
 void setDeathCondition(Probability probability)
          The probability that a boids die.
 void setDirectionFactor(double directionFactor)
          Change the importance of the other boids direction "overall" vector.
 void setFearFactor(double fearFactor)
          Change the factor for repulsion on boids of other species.
 void setInertia(double inertia)
          Change the inertia is the importance of the boid previous direction in the boid direction.
 void setMaxSpeed(double maxSpeed)
          Change the maximum speed bound.
 void setMinSpeed(double minSpeed)
          Change the minimum speed bound.
 void setReproductionProbability(Probability probability)
          The probability that a boids clones itself.
 void setRepulsionFactor(double repulsionFactor)
          Change how all the visible boids repulse the boid.
 void setSpeedFactor(double speedFactor)
          Change the boid speed at each step.
 void setViewZone(double viewZone)
          Change the distance at which a boid is seen.
 void terminateStep(double time)
          This method is called by BoidGraph at the end of each step.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoidSpecies

public BoidSpecies(BoidGraph ctx,
                   String name)
New default species with a random color.

Parameters:
ctx - context in which this species is evolving
name - final name of this species
Method Detail

getName

public String getName()
Getter for the name of the species.

Returns:
name of this species

set

public void set(String p,
                String val)
         throws IllegalArgumentException
Same than set(Parameter, String) but the enum constant is given as a string.

Parameters:
p - name of the enum constant associated with a parameter. Note that this name is case-independent since it is converted to upper case in the method
val - string value of the parameter
Throws:
IllegalArgumentException - if the enum constant does not exist

set

public void set(BoidSpecies.Parameter p,
                String val)
Utility function to set parameter from an enum constant and a string value.

Parameters:
p - an enum constant associated with a parameter
val - string value of the parameter

createNewId

public String createNewId()
Create a new unique id specific to this species. It can be used to create a new boid.

Returns:
a new unique id

createBoid

public Boid createBoid()
Create a new boid with an automatic id created using createNewId().

Returns:
a new boid

createBoid

public Boid createBoid(String id)
Create a new boid.

Parameters:
id - id of the new boid
Returns:
the new boid

terminateStep

public void terminateStep(double time)
This method is called by BoidGraph at the end of each step. It can be used by sub-classes to add some code.

Parameters:
time - The current boid graph time.

getPopulation

public int getPopulation()
Count of boids of this species.

Returns:
boids count

setCount

public void setCount(int count)
Create boids until population is at least count. If population is already greater than count, nothing happens.

Parameters:
count - the minimum boid count for this species

getViewZone

public double getViewZone()
The distance at which a boid is seen.

Returns:

setViewZone

public void setViewZone(double viewZone)
Change the distance at which a boid is seen.

Parameters:
viewZone -

getSpeedFactor

public double getSpeedFactor()
The boid speed at each step. This is the factor by which the speedFactor vector is scaled to move the boid at each step. This therefore not only accelerate the boid displacement, it also impacts the boid behavior (oscillation around the destination point, etc.)

Returns:

setSpeedFactor

public void setSpeedFactor(double speedFactor)
Change the boid speed at each step.

Parameters:
speedFactor -

getMaxSpeed

public double getMaxSpeed()
Maximum speed bound.

Returns:

setMaxSpeed

public void setMaxSpeed(double maxSpeed)
Change the maximum speed bound.

Parameters:
maxSpeed -

getMinSpeed

public double getMinSpeed()
Minimum speed bound.

Returns:

setMinSpeed

public void setMinSpeed(double minSpeed)
Change the minimum speed bound.

Parameters:
minSpeed -

getDirectionFactor

public double getDirectionFactor()
The importance of the other boids direction "overall" vector. The direction vector is the sum of all the visible boids direction vector divided by the number of boids seen. This factor is the importance of this direction in the boid direction.

Returns:

setDirectionFactor

public void setDirectionFactor(double directionFactor)
Change the importance of the other boids direction "overall" vector.

Parameters:
directionFactor -

getAttractionFactor

public double getAttractionFactor()
How much other visible boids attract a boid. The barycenter of the visible boids attract a boid. The attraction is the vector between the boid an this barycenter. This factor is the importance of this vector in the boid direction.

Returns:

setAttractionFactor

public void setAttractionFactor(double attractionFactor)
Change how much other visible boids attract a boid.

Parameters:
attractionFactor -

getRepulsionFactor

public double getRepulsionFactor()
All the visible boids repulse the boid. The repulsion vector is the sum of all the vectors between all other visible boids and the considered boid, scaled by the number of visible boids. This factor is the importance of this vector in the boid direction.

Returns:

setRepulsionFactor

public void setRepulsionFactor(double repulsionFactor)
Change how all the visible boids repulse the boid.

Parameters:
repulsionFactor -

getInertia

public double getInertia()
The inertia is the importance of the boid previous direction in the boid direction.

Returns:

setInertia

public void setInertia(double inertia)
Change the inertia is the importance of the boid previous direction in the boid direction.

Parameters:
inertia -

getFearFactor

public double getFearFactor()
Factor for repulsion on boids of other species. The fear that this species produces on other species.

Returns:

setFearFactor

public void setFearFactor(double fearFactor)
Change the factor for repulsion on boids of other species.

Parameters:
fearFactor -

getColor

public Color getColor()
The species main color.

Returns:

setColor

public void setColor(Color color)
Change the species main color.

Parameters:
color -

getAngleOfView

public double getAngleOfView()
The boid angle of view, [-1..1]. This is the cosine of the angle between the boid direction and the direction toward another boid. -1 Means 360 degrees, all is visible. 0 means 180 degrees only boids in front are visible, 0.5 means 90 degrees, 0.25 means 45 degrees.

Returns:
angle of view for boid of this species

setAngleOfView

public void setAngleOfView(double aov)
Set the angle of view for boids of this species.

Parameters:
aov - new angle of view

setReproductionProbability

public void setReproductionProbability(Probability probability)
The probability that a boids clones itself.

Parameters:
probability - A probability instance.

setDeathCondition

public void setDeathCondition(Probability probability)
The probability that a boids die.

Parameters:
probability - A probability instance.

release

public void release()
Unregister this species from the boids graph. This removes all boids pertaining to this species, and release the link with the graph.


iterator

public Iterator<Boid> iterator()
Specified by:
iterator in interface Iterable<Boid>


Copyright © 2013. All Rights Reserved.