org.vizzini.game.boardgame
Class AbstractGameGeneticAlgorithm

java.lang.Object
  extended by org.vizzini.ai.geneticalgorithm.AbstractGeneticAlgorithm
      extended by org.vizzini.game.boardgame.AbstractGameGeneticAlgorithm
All Implemented Interfaces:
IGameGeneticAlgorithm, IGeneticAlgorithm
Direct Known Subclasses:
TicTacToeGeneticAlgorithm

public abstract class AbstractGameGeneticAlgorithm
extends AbstractGeneticAlgorithm
implements IGameGeneticAlgorithm

Provides base functionality for game genetic algorithms in the game framework.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
 
Fields inherited from class org.vizzini.ai.geneticalgorithm.AbstractGeneticAlgorithm
_crossoverFraction, _crossoverType, _elapsedTime, _generation
 
Constructor Summary
AbstractGameGeneticAlgorithm()
          Construct this object using the given parameters.
 
Method Summary
protected  void configureAgent(IComputerAgent agent, IChromosome chromosome)
          Configure the given agent for play.
protected abstract  IComputerAgent createAgent0()
          Create agent 0.
protected abstract  IComputerAgent createAgent1()
          Create agent 0.
protected  IGame createGame()
          Create the game.
protected  void evaluateFitness()
          Evaluate the fitness of all chromosomes in the population.
 int getFitnessLoss()
          Return the fitness loss value.
 int getFitnessTie()
          Return the fitness tie value.
 int getFitnessWin()
          Return the fitness win value.
protected  IGame getGame()
          Return the game.
protected abstract  String getGamePropertiesPath()
          Return the game properties path.
protected  int getMaxOpponentCount()
          Return the maximum opponent count.
protected  boolean isVerbose()
          Return true if the verbose flag is set.
protected  void rewardAndPunish(int i, int j)
          Reward and punish the given chromosomes.
protected  void setAgent0(IComputerAgent agent)
          Set the first agent.
protected  void setAgent1(IComputerAgent agent)
          Set the second agent.
 void setFitnessLoss(int fitness)
          Set the fitness loss value.
 void setFitnessTie(int fitness)
          Set the fitness tie value.
 void setFitnessWin(int fitness)
          Set the fitness win value.
protected  void setGame(IGame game)
          Set the game.
 void setTurnNumberConsidered(boolean isTurnNumberConsidered)
          Set the flag which indicates whether the turn number is used in reward and punishment.
 void setVerbose(boolean isVerbose)
          Set the flag which indicates whether to provide text output.
 String toString()
          Return a string representation of this object.
protected  void zeroCounts()
          Zero the counts.
 
Methods inherited from class org.vizzini.ai.geneticalgorithm.AbstractGeneticAlgorithm
averageCrossover, createChromosome, fillPopulation, generateNewPopulation, getAverageCrossoverFraction, getCrossoverFraction, getCrossoverType, getElapsedTime, getGeneration, getMostFit, getMutationFraction, getMutationMagnitude, getMutationRate, getPerfectFitness, getPopulation, getPopulationSize, getProcessingRate, isDuplicateAllowed, mutation, onePointCrossover, reproductionAndCrossover, reset, runGenerations, setAverageCrossoverFraction, setCrossoverFraction, setCrossoverType, setDuplicateAllowed, setMutationFraction, setMutationMagnitude, setMutationRate, setPopulation, setPopulationSize, sortPopulation, uniformCrossover, writeReport, writeStats, writeStatsHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.ai.geneticalgorithm.IGeneticAlgorithm
getCrossoverFraction, getCrossoverType, getElapsedTime, getGeneration, getMostFit, getMutationFraction, getMutationMagnitude, getMutationRate, getPopulationSize, getProcessingRate, reset, runGenerations, setAverageCrossoverFraction, setCrossoverFraction, setCrossoverType, setDuplicateAllowed, setMutationFraction, setMutationMagnitude, setMutationRate, setPopulationSize, writeReport
 

Constructor Detail

AbstractGameGeneticAlgorithm

public AbstractGameGeneticAlgorithm()
                             throws InstantiationException,
                                    IllegalAccessException
Construct this object using the given parameters.

Throws:
InstantiationException
IllegalAccessException
Since:
v0.1
Method Detail

getFitnessLoss

public int getFitnessLoss()
Return the fitness loss value.

Specified by:
getFitnessLoss in interface IGameGeneticAlgorithm
Since:
v0.1

getFitnessTie

public int getFitnessTie()
Return the fitness tie value.

Specified by:
getFitnessTie in interface IGameGeneticAlgorithm
Since:
v0.1

getFitnessWin

public int getFitnessWin()
Return the fitness win value.

Specified by:
getFitnessWin in interface IGameGeneticAlgorithm
Since:
v0.1

setFitnessLoss

public void setFitnessLoss(int fitness)
Set the fitness loss value. Typically this value is negative.

Specified by:
setFitnessLoss in interface IGameGeneticAlgorithm
Since:
v0.1

setFitnessTie

public void setFitnessTie(int fitness)
Set the fitness tie value.

Specified by:
setFitnessTie in interface IGameGeneticAlgorithm
Since:
v0.1

setFitnessWin

public void setFitnessWin(int fitness)
Set the fitness win value. Typically this value is positive.

Specified by:
setFitnessWin in interface IGameGeneticAlgorithm
Since:
v0.1

setTurnNumberConsidered

public void setTurnNumberConsidered(boolean isTurnNumberConsidered)
Set the flag which indicates whether the turn number is used in reward and punishment.

Since:
v0.1

setVerbose

public void setVerbose(boolean isVerbose)
Set the flag which indicates whether to provide text output.

Specified by:
setVerbose in interface IGameGeneticAlgorithm
Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class AbstractGeneticAlgorithm
Since:
v0.1

createAgent0

protected abstract IComputerAgent createAgent0()
Create agent 0.

Since:
v0.1

createAgent1

protected abstract IComputerAgent createAgent1()
Create agent 0.

Since:
v0.1

getGamePropertiesPath

protected abstract String getGamePropertiesPath()
Return the game properties path.

Since:
v0.1

configureAgent

protected void configureAgent(IComputerAgent agent,
                              IChromosome chromosome)
Configure the given agent for play.

Since:
v0.1

createGame

protected IGame createGame()
                    throws InstantiationException,
                           IllegalAccessException
Create the game.

Throws:
InstantiationException
IllegalAccessException
Since:
v0.1

evaluateFitness

protected void evaluateFitness()
Evaluate the fitness of all chromosomes in the population.

Specified by:
evaluateFitness in class AbstractGeneticAlgorithm
Since:
v0.1

getGame

protected IGame getGame()
Return the game.

Since:
v0.1

getMaxOpponentCount

protected int getMaxOpponentCount()
Return the maximum opponent count.

Since:
v0.3

isVerbose

protected boolean isVerbose()
Return true if the verbose flag is set.

Since:
v0.1

rewardAndPunish

protected void rewardAndPunish(int i,
                               int j)
Reward and punish the given chromosomes.

Since:
v0.1

setAgent0

protected void setAgent0(IComputerAgent agent)
Set the first agent.

Since:
v0.1

setAgent1

protected void setAgent1(IComputerAgent agent)
Set the second agent.

Since:
v0.1

setGame

protected void setGame(IGame game)
Set the game.

Since:
v0.1

zeroCounts

protected void zeroCounts()
Zero the counts.

Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02