critter
Class Critter

java.lang.Object
  |
  +--critter.Critter

public class Critter
extends java.lang.Object


Field Summary
 int dir_x
           
 int dir_y
           
static int DIRECTION_X
           
static int DIRECTION_Y
           
 int energy
           
 int x
           
 int y
           
 
Constructor Summary
Critter(critter.Critter p1, critter.Critter p2)
          Constructs a new critter from two parent critters For each neuron wiring, it takes one of the parents' wiring.
Critter(long seed)
          Constructs a new critter Initializes the "brain".
 
Method Summary
 int[] act()
          The control function.
 void eat()
          The function which is called whenever the critter finds food, increases energy level (and lifetime).
 double fitness()
          The fitness/objective function
 void mutate(double prob)
          Mutate the critters neuron wires by a probability
 void percept(int[] sig)
          The function which is called whenever the critter needs to update its senses.
 void print()
          Helper function to print out details of a critter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTION_X

public static int DIRECTION_X

DIRECTION_Y

public static int DIRECTION_Y

energy

public int energy

x

public int x

y

public int y

dir_x

public int dir_x

dir_y

public int dir_y
Constructor Detail

Critter

public Critter(long seed)
Constructs a new critter Initializes the "brain".

Parameters:
seed - the seed use for the random generator

Critter

public Critter(critter.Critter p1,
               critter.Critter p2)
Constructs a new critter from two parent critters For each neuron wiring, it takes one of the parents' wiring.

Method Detail

mutate

public void mutate(double prob)
Mutate the critters neuron wires by a probability

Parameters:
prob - the probability by which each wire is flipped

fitness

public double fitness()
The fitness/objective function

Returns:
the quantified performance of the agent reflecting the survival rate

percept

public void percept(int[] sig)
The function which is called whenever the critter needs to update its senses. The function needs to store the readings for control.

Parameters:
sig - the sensor readings

act

public int[] act()
The control function. Proposes a particular motor signal and returns it for execution in the world.

Returns:
motor signal

eat

public void eat()
The function which is called whenever the critter finds food, increases energy level (and lifetime).


print

public void print()
Helper function to print out details of a critter. Is called whenever the user clicks on a critter on the grid.