org.generation5.demos
Class SpatialIPD

java.lang.Object
  extended byorg.generation5.bio.CellularAutomata
      extended byorg.generation5.demos.SpatialIPD
All Implemented Interfaces:
Steppable, Visualizable

public class SpatialIPD
extends CellularAutomata

Implements a spatial version of the iterated prisoner's dilemma. Five different strategies are placed randomly within the world and are pitted against each other. The five strategies and their corresponding colours are:


Field Summary
protected  PrisonersDilemmaAgent[][] ipdAgents
          The agents used in the world.
protected  double noiseRate
          The noise rate.
protected  int trialRuns
          The number of trail per agent, per neighbour, per iteration.
 
Fields inherited from class org.generation5.bio.CellularAutomata
bufferPosition, bufferSize, caSize, caWorld, caWorld_x, caWorld_y, clrBackground, clrGrid, clrWorld, DOUBLE_BUFFERING, doubleBuffering, drawGrid, ENCLOSED, geometryType, INFINITE, TORODIAL, X_AXIS, Y_AXIS
 
Constructor Summary
SpatialIPD()
          Creates a new instance of SpatialIPD
SpatialIPD(int size_x, int size_y)
          Creates a new instance with world size information.
 
Method Summary
 void doStep()
          Advance the Spatial IPD one timestep.
 double getNoiseRate()
          Retrieve the noise rate.
 void init()
          Initialize the world to a random collection of strategies.
static void main(java.lang.String[] args)
           
 void setNoiseRate(double nr)
          Set the noise rate to be used within the world.
 void setWorldSize(int size_x, int size_y)
          Set the world size.
 
Methods inherited from class org.generation5.bio.CellularAutomata
clearWorld, drawGrid, flipBuffer, getBackgroundColor, getCASize, getGeometry, getSizeX, getSizeY, getWorldAt, iterateCA, iterateCA, render, reset, setBackgroundColor, setCASize, setGeometry, setWorldAt, setWorldAtEx, setWorldAtRelative, setWorldColors, setWorldColour, translateGeometry, writeImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trialRuns

protected int trialRuns
The number of trail per agent, per neighbour, per iteration.


noiseRate

protected double noiseRate
The noise rate.


ipdAgents

protected PrisonersDilemmaAgent[][] ipdAgents
The agents used in the world.

Constructor Detail

SpatialIPD

public SpatialIPD()
Creates a new instance of SpatialIPD


SpatialIPD

public SpatialIPD(int size_x,
                  int size_y)
Creates a new instance with world size information.

Parameters:
size_x - the x-size of the world.
size_y - the y-size of the world.
Method Detail

setNoiseRate

public void setNoiseRate(double nr)
Set the noise rate to be used within the world. The noise rate causes strategies to mutate every now and again.

Parameters:
nr - the noise rate.

getNoiseRate

public double getNoiseRate()
Retrieve the noise rate.

Returns:
the noise rate.

setWorldSize

public void setWorldSize(int size_x,
                         int size_y)
Set the world size.

Overrides:
setWorldSize in class CellularAutomata
Parameters:
size_x - the x-size of the world.
size_y - the y-size of the world.

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments passed to iterateCA.

doStep

public void doStep()
Advance the Spatial IPD one timestep.

Specified by:
doStep in interface Steppable
Specified by:
doStep in class CellularAutomata

init

public void init()
Initialize the world to a random collection of strategies.

Specified by:
init in interface Steppable
Specified by:
init in class CellularAutomata

This documentation is part of the Generation5 JDK.