GeneThello Home

net.sf.genethello.brain
Class Chromosome

java.lang.Object
  extended by net.sf.genethello.brain.Chromosome

public class Chromosome
extends java.lang.Object

Chromosome to represent individual othello player (brain).

Author:
praz

Field Summary
protected  int[] boundaries
          Array of phase boundaries int[phases + 1].
protected  Feature[][] features
          Matrix of features Feature[phases][length].
protected  int length
          Number of features, usually 6 i.e.: flips, discs, mobility, xquares, corners, pattern.
protected  int[] maxBoundaries
          Array of maximum phase boundaries int[phases + 1].
protected  int[] minBoundaries
          Array of minimum phase boundaries int[phases + 1].
protected  int phases
          Phase number in game, usually 3 phases: opening, middle, end.
 
Constructor Summary
Chromosome(int phases, int length)
          Creates new instance of chromosome.
 
Method Summary
 int[] getBoundaries()
          Gets the value of boundaries.
 int getBoundaries(int index)
          Gets the value of boundaries at specified index.
 Feature getFeatures(int p, int i)
          Gets the value of features.
 int getLength()
          Gets the value of length
 int getMaxBoundaries(int index)
          Gets the value of maximum boundaries at specified index.
 int getMinBoundaries(int index)
          Gets the value of minimum boundaries at specified index.
 int getPhases()
          Gets the value of phases
 void setBoundaries(int[] boundaries)
          Sets the value of boundaries.
 void setBoundaries(int index, int newBoundaries)
          Sets the value of boundaries at specified index.
 void setBoundaries(int index, int newBoundaries, int min, int max)
          Sets the value of boundaries at specified index.
 void setFeatures(int p, int i, Feature feature)
          Sets the value of features.
 void setLength(int length)
          Sets the value of length
 void setPhases(int phases)
          Sets the value of phases
 int size()
          Gets size of chromosome in total number of weight to be optimized.
 org.jgap.Chromosome toJgapChromosome(org.jgap.Configuration conf)
          JGAP representation of chromosome.
 java.lang.String toString()
          String representation of chromosome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

length

protected int length
Number of features, usually 6 i.e.: flips, discs, mobility, xquares, corners, pattern.


phases

protected int phases
Phase number in game, usually 3 phases: opening, middle, end.


features

protected Feature[][] features
Matrix of features Feature[phases][length].


boundaries

protected int[] boundaries
Array of phase boundaries int[phases + 1].


minBoundaries

protected int[] minBoundaries
Array of minimum phase boundaries int[phases + 1].


maxBoundaries

protected int[] maxBoundaries
Array of maximum phase boundaries int[phases + 1].

Constructor Detail

Chromosome

public Chromosome(int phases,
                  int length)
Creates new instance of chromosome.

Parameters:
phases - phase number in game, usually 3 phases: opening, middle, end
length - number of features, usually 6 i.e.: flips, discs, mobility, xsquares, corners, pattern
Method Detail

size

public int size()
Gets size of chromosome in total number of weight to be optimized.

Returns:
size of chromosome

getLength

public int getLength()
Gets the value of length

Returns:
the value of length

setLength

public void setLength(int length)
Sets the value of length

Parameters:
length - new value of length

getPhases

public int getPhases()
Gets the value of phases

Returns:
the value of phases

setPhases

public void setPhases(int phases)
Sets the value of phases

Parameters:
phases - new value of phases

getFeatures

public Feature getFeatures(int p,
                           int i)
Gets the value of features.

Parameters:
p - phase number
i - index
Returns:
feature value

setFeatures

public void setFeatures(int p,
                        int i,
                        Feature feature)
Sets the value of features.

Parameters:
p - phase number
i - index
feature - feature value

getBoundaries

public int[] getBoundaries()
Gets the value of boundaries.

Returns:
the value of boundaries

setBoundaries

public void setBoundaries(int[] boundaries)
Sets the value of boundaries.

Parameters:
boundaries - new value of boundaries

getBoundaries

public int getBoundaries(int index)
Gets the value of boundaries at specified index.

Parameters:
index -
Returns:
the value of boundaries at specified index

getMinBoundaries

public int getMinBoundaries(int index)
Gets the value of minimum boundaries at specified index.

Parameters:
index -
Returns:
the value of minimum boundaries at specified index

getMaxBoundaries

public int getMaxBoundaries(int index)
Gets the value of maximum boundaries at specified index.

Parameters:
index -
Returns:
the value of maximum boundaries at specified index

setBoundaries

public void setBoundaries(int index,
                          int newBoundaries)
Sets the value of boundaries at specified index.

Parameters:
index -
newBoundaries - new value of boundaries at specified index

setBoundaries

public void setBoundaries(int index,
                          int newBoundaries,
                          int min,
                          int max)
Sets the value of boundaries at specified index.

Parameters:
index -
newBoundaries - new value of boundaries at specified index
min - minimum value of boundaries at specified index
max - maximum value of boundaries at specified index

toString

public java.lang.String toString()
String representation of chromosome.

Overrides:
toString in class java.lang.Object
Returns:
string representation

toJgapChromosome

public org.jgap.Chromosome toJgapChromosome(org.jgap.Configuration conf)
                                     throws org.jgap.InvalidConfigurationException
JGAP representation of chromosome.

Parameters:
conf - configuratoin of chromosome
Returns:
JGAP representation
Throws:
org.jgap.InvalidConfigurationException

GeneThello Home

Get GeneThello: Genetic Othello at SourceForge.net. Fast, secure and Free Open Source software downloads