critter
Class World

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

public class World
extends java.lang.Object


Constructor Summary
World(int x, int y, long seed)
          Constructs the world of a given size
 
Method Summary
 boolean addCritter(critter.Critter obj)
          Adds a critter to the world, position and direction are randomly chosen
 boolean addCritter(critter.Critter obj, int x, int y, int dir_x, int dir_y)
          Adds a critter to a specified position in the world and with a specified direction
 boolean empty(int x, int y)
          true if the position is empty (no obstacle, food or critter
 void init(double foodRate, double obstacleRate)
          populates the world with food and obstacles
 int peek(int x, int y)
          Retrieves the object found in a particular position on the grid
 void updateMoves()
          Each critter's act method is called and executed in the world.
 void updateSenses()
          Updates the state of all critters, has complete control over signals (the way the world gives rise to sensor readings).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

World

public World(int x,
             int y,
             long seed)
Constructs the world of a given size

Parameters:
x - number of positions along x-axis
y - number of positions along y-axis
seed - seed for the random number generator
Method Detail

init

public void init(double foodRate,
                 double obstacleRate)
populates the world with food and obstacles


peek

public int peek(int x,
                int y)
Retrieves the object found in a particular position on the grid


empty

public boolean empty(int x,
                     int y)
true if the position is empty (no obstacle, food or critter


addCritter

public boolean addCritter(critter.Critter obj,
                          int x,
                          int y,
                          int dir_x,
                          int dir_y)
Adds a critter to a specified position in the world and with a specified direction


addCritter

public boolean addCritter(critter.Critter obj)
Adds a critter to the world, position and direction are randomly chosen


updateSenses

public void updateSenses()
Updates the state of all critters, has complete control over signals (the way the world gives rise to sensor readings). Each critter gets a 6-element sensor vector: [0] range to FOOD ahead (a value 3 - 0, where 3 is FOOD is in the next position, and 0 is no FOOD insight) [1] range to FOOD to the left [2] range to FOOD to the right [3] range to OBSTACLE/CRITTER ahead [4] range to OBSTACLE/CRITTER to the left [5] range to OBSTACLE/CRITTER to the right


updateMoves

public void updateMoves()
Each critter's act method is called and executed in the world. Controls how the neurons of the critter translate into movements, if allowed etc. The critter has two wheels, two neurons connect to the wheels, each producing -1/0/+1 for reverse/still/forward rotation.