Package simulation

Class Dna

java.lang.Object
simulation.Dna

public class Dna
extends java.lang.Object
Represents genetic information of species
  • Constructor Summary

    Constructors 
    Constructor Description
    Dna​(double forceMultiplier)
    Generate completely new Dna object filled with random values.
    Dna​(Dna parent1, Dna parent2)
    Create a new Dna object from crossover of other already existing Dna objects.
  • Method Summary

    Modifier and Type Method Description
    void fullMutate()
    If random value (1,0) is smaller that full mutation chance, perform full mutation of this object.
    Vector[] getAcceleration()
    Get the acceleration vector of this dna object.
    void mutate()
    Perform mutation of random acceleration values.
    Vector readNextDna()
    Read next acceleration value in the array and move pointer by 1.
    java.lang.String toString()
    Builds string based of acceleration Vector values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Dna

      public Dna​(Dna parent1, Dna parent2)
      Create a new Dna object from crossover of other already existing Dna objects.
      Parameters:
      parent1 - First object to generate Dna from.
      parent2 - Second object to generate Dna from.
    • Dna

      public Dna​(double forceMultiplier)
      Generate completely new Dna object filled with random values.
      Parameters:
      forceMultiplier - Maximum acceleration force.
  • Method Details

    • getAcceleration

      public Vector[] getAcceleration()
      Get the acceleration vector of this dna object.
      Returns:
      Vector filled with acceleration values.
    • readNextDna

      public Vector readNextDna()
      Read next acceleration value in the array and move pointer by 1.
      Returns:
      Acceleration value. If pointer reached end of an array, return null
    • mutate

      public void mutate()
      Perform mutation of random acceleration values.
    • fullMutate

      public void fullMutate()
      If random value (1,0) is smaller that full mutation chance, perform full mutation of this object.
    • toString

      public java.lang.String toString()
      Builds string based of acceleration Vector values.
      Overrides:
      toString in class java.lang.Object
      Returns:
      String containing all Vector values as one line of csv format.