Package simulation
Class Dna
java.lang.Object
simulation.Dna
public class Dna
extends java.lang.Object
Represents genetic information of species
-
Constructor Summary
-
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.
-
Constructor Details
-
Dna
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
Get the acceleration vector of this dna object.- Returns:
- Vector filled with acceleration values.
-
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 classjava.lang.Object
- Returns:
- String containing all Vector values as one line of csv format.
-