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 double calcFitness()
    Calculate fitness of this object.
    Dna getDna()
    Get this species genetic information in form of an Dna object.
    double getFitness()
    Get the fitness of this object.
    int getHeight()
    Get this population member render height.
    static Vector getInitialVelocity()
    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 Vector getStartCoordinates()
    Get this species start coordinates.
    int getWidth()
    Get this population member render width.
    boolean isDead()
    Check if this object is dead.
    boolean isNaturalDead()
    Check if this population member died naturally (didn't bump into obstacle).
    void setDead​(boolean dead)
    Set whether this object is dead or not.
    void setDna​(Dna dna)
    Set this objects Dna to be different.
    void setFitness​(double fitness)
    Set fitness value to be different.
    void setHeight​(int height)
    Set render height of this object.
    void setNaturalDead​(boolean naturalDead)
    Set natural death of this population member.
    void setWidth​(int width)
    Set this population member render width.

    Methods inherited from class simulation.Movable

    addVelocity, getVelocity, multiply, multiply, setVelocity

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface simulation.Drawable

    draw
  • Constructor Details

  • 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

      public static Vector getInitialVelocity()
      Get this objects initial velocity.
      Returns:
    • getStartCoordinates

      public static Vector getStartCoordinates()
      Get this species start coordinates.
      Returns:
      a vector containing this start coordinates.
    • getDna

      public Dna getDna()
      Get this species genetic information in form of an Dna object.
      Returns:
      this objects DNA.
    • setDna

      public void setDna​(Dna dna)
      Set this objects Dna to be different.
      Parameters:
      dna - a dna to be set to.
    • getObstacles

      public static java.util.ArrayList<Obstacle> 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.