public class Chromosome extends java.lang.Object implements java.lang.Comparable<Chromosome>
Constructor and Description |
---|
Chromosome(java.lang.String[][] ruleset,
SLDescription sl)
Chromosome constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateFitness(long time)
calculates the fitness, by comparing the scores of a naiveAI and a smart AI
|
void |
cleanseChromosome() |
Chromosome |
clone()
clone the chromosome data
|
int |
compareTo(Chromosome o)
Compare two chromosome with each other based on their
constrained fitness and normal fitness
|
java.util.ArrayList<Chromosome> |
crossover(Chromosome c)
crossover the current chromosome with the input chromosome
|
double |
getConstrainFitness()
Get constraint fitness for infeasible chromosome
|
java.util.ArrayList<java.lang.Double> |
getFitness()
Returns the fitness of the chromosome
|
java.lang.String[][] |
getRuleset()
returns the ruleset of this chromosome
|
void |
mutate()
Flips a coin to see if we mutate on termination or interaction
|
void |
mutateInteraction()
performs a mutation on a random interaction in the set
4 types of mutation: insert a new rule, delete an old rule, change a rule, and change rule parameters (but keep the rule)
the interaction ruleset will shift back and forth between an array and an arraylist depending on the circumstances
according to what is easiest to manipulate at the time
|
void |
mutateTermination()
performs a mutation on a random termination in the set
4 types of mutation: insert a new rule, delete an old rule, change a rule, and change rule parameters (but keep the rule)
the termination ruleset will shift back and forth between an array and an arraylist depending on the circumstances
according to what is easiest to manipulate at the time.
|
void |
setRuleset(java.lang.String[][] nRuleset)
sets the ruleset
|
public Chromosome(java.lang.String[][] ruleset, SLDescription sl)
ruleset
- the ruleset the chromosome containssl
- the game descriptiontime
- elapsed timepublic void mutate()
public void mutateInteraction()
public void mutateTermination()
public Chromosome clone()
clone
in class java.lang.Object
public void cleanseChromosome()
public void calculateFitness(long time)
time
- how much time to evaluate the chromosomepublic java.util.ArrayList<Chromosome> crossover(Chromosome c)
c
- the other chromosome to crossover withpublic int compareTo(Chromosome o)
compareTo
in interface java.lang.Comparable<Chromosome>
public java.util.ArrayList<java.lang.Double> getFitness()
public double getConstrainFitness()
public java.lang.String[][] getRuleset()
public void setRuleset(java.lang.String[][] nRuleset)
nRuleset
- the new ruleset