Package simulation
Class PopulationMember
java.lang.Object
simulation.Movable
simulation.PopulationMember
- All Implemented Interfaces:
Drawable
- Direct Known Subclasses:
FastPopulationMember,SlowPopulationMember
public abstract class PopulationMember extends Movable implements Drawable
Common features of all population members.
-
Constructor Summary
Constructors Constructor Description PopulationMember()Create new PopulationMember. -
Method Summary
Modifier and Type Method Description abstract doublecalcFitness()Calculate fitness of this object.DnagetDna()Get this species genetic information in form of an Dna object.doublegetFitness()Get the fitness of this object.intgetHeight()Get this population member render height.static VectorgetInitialVelocity()Get this objects initial velocity.static java.util.ArrayList<Obstacle>getObstacles()Get an ArrayList of all obstacles that are seen by this population member.static VectorgetStartCoordinates()Get this species start coordinates.intgetWidth()Get this population member render width.booleanisDead()Check if this object is dead.booleanisNaturalDead()Check if this population member died naturally (didn't bump into obstacle).voidsetDead(boolean dead)Set whether this object is dead or not.voidsetDna(Dna dna)Set this objects Dna to be different.voidsetFitness(double fitness)Set fitness value to be different.voidsetHeight(int height)Set render height of this object.voidsetNaturalDead(boolean naturalDead)Set natural death of this population member.voidsetWidth(int width)Set this population member render width.Methods inherited from class simulation.Movable
addVelocity, getVelocity, multiply, multiply, setVelocity
-
Constructor Details
-
PopulationMember
public PopulationMember()Create new PopulationMember.
-
-
Method Details
-
isNaturalDead
public boolean isNaturalDead()Check if this population member died naturally (didn't bump into obstacle).- Returns:
- whether it died naturally or not.
-
setNaturalDead
public void setNaturalDead(boolean naturalDead)Set natural death of this population member.- Parameters:
naturalDead- whether a natural death occured or not.
-
calcFitness
public abstract double calcFitness()Calculate fitness of this object. Fitness is a value telling how good is genetic information of this object. The bigger the value the higher the chance of this species genetic information to survive.- Returns:
- Fitness of this object.
-
getFitness
public double getFitness()Get the fitness of this object.- Returns:
- fitness
-
setFitness
public void setFitness(double fitness)Set fitness value to be different.- Parameters:
fitness- a desired fitness value.
-
getInitialVelocity
Get this objects initial velocity.- Returns:
-
getStartCoordinates
Get this species start coordinates.- Returns:
- a vector containing this start coordinates.
-
getDna
Get this species genetic information in form of an Dna object.- Returns:
- this objects DNA.
-
setDna
Set this objects Dna to be different.- Parameters:
dna- a dna to be set to.
-
getObstacles
Get an ArrayList of all obstacles that are seen by this population member.- Returns:
- list of all obstacles.
-
getWidth
public int getWidth()Get this population member render width.- Returns:
- render width
-
setWidth
public void setWidth(int width)Set this population member render width.- Parameters:
width- render width
-
getHeight
public int getHeight()Get this population member render height.- Returns:
- render height
-
setHeight
public void setHeight(int height)Set render height of this object.- Parameters:
height- render height
-
isDead
public boolean isDead()Check if this object is dead.- Returns:
- Whether it is dead or not.
-
setDead
public void setDead(boolean dead)Set whether this object is dead or not.- Parameters:
dead- specified value.
-