|
Jadex 0.96 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjadex.examples.hunterprey.Environment
public class Environment
The environment is the container all objects and creatures.
Field Summary | |
---|---|
static int |
DEFAULT_LEASE_TICKS
The default number of lease ticks. |
MultiCollection |
world
All world objects accessible per location. |
Constructor Summary | |
---|---|
Environment()
Create a new environment. |
Method Summary | |
---|---|
Creature |
addCreature(Creature creature)
Add a new creature to the world. |
TaskInfo |
addEatTask(Creature me,
WorldObject obj)
Add a move or eat action to the queue. |
void |
addFood(Food nfood)
Add a new prey food to the world. |
TaskInfo |
addMoveTask(Creature me,
String dir)
Add a move or eat action to the queue. |
void |
addObstacle(Obstacle obstacle)
Add a new obstacle to the world. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
boolean |
eat(Creature me,
WorldObject food)
Eat some object. |
void |
executeStep()
Execute a step. |
WorldObject[] |
getAllObjects()
Get all objects in the world (obstacles, food, and creature). |
Creature[] |
getCreatures()
Get the creatures. |
Food[] |
getFood()
Get the obstacles. |
int |
getFoodrate()
Get the foodrate. |
int |
getHeight()
Get the height of the world. |
Creature[] |
getHighscore()
Get the current highscore. |
static Environment |
getInstance()
Get the singleton. |
Obstacle[] |
getObstacles()
Get the obstacles. |
long |
getSaveInterval()
Get the highscore save interval (-1 for autosave off). |
int |
getTaskSize()
Return the size of the task list. |
Vision |
getVision(Creature me)
Get the current vision. |
int |
getWidth()
Get the width of the world. |
int |
getWorldAge()
Get the world age. |
Vision |
internalGetVision(Creature me)
Get the current vision (without updating the creatures leaseticks). |
boolean |
move(Creature me,
String dir)
Perform a move. |
boolean |
moveDown(Creature me)
Move one field downwards. |
boolean |
moveLeft(Creature me)
Move one field to the left. |
boolean |
moveRight(Creature me)
Move one field to the right. |
boolean |
moveUp(Creature me)
Move one field upwards. |
boolean |
removeCreature(Creature creature)
Remove a creature to the world. |
boolean |
removeFood(Food nfood)
remove a prey food to the world. |
boolean |
removeObstacle(Obstacle obstacle)
Remove a obstacle to the world. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
saveHighscore()
Save the highscore to a file. |
void |
setFoodrate(int foodrate)
Set the foodrate. |
void |
setSaveInterval(long saveinterval)
Set the highscore save interval (-1 for autosave off). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int DEFAULT_LEASE_TICKS
public MultiCollection world
Constructor Detail |
---|
public Environment()
Method Detail |
---|
public static Environment getInstance()
public boolean moveUp(Creature me)
moveUp
in interface IEnvironment
public boolean moveDown(Creature me)
moveDown
in interface IEnvironment
public boolean moveLeft(Creature me)
moveLeft
in interface IEnvironment
public boolean moveRight(Creature me)
moveRight
in interface IEnvironment
public boolean eat(Creature me, WorldObject food)
eat
in interface IEnvironment
food
- The object.
public TaskInfo addEatTask(Creature me, WorldObject obj)
public TaskInfo addMoveTask(Creature me, String dir)
public Vision internalGetVision(Creature me)
me
- The creature.public Vision getVision(Creature me)
getVision
in interface IEnvironment
me
- The creature.public int getWidth()
public int getHeight()
public void addFood(Food nfood)
nfood
- The new food.public boolean removeFood(Food nfood)
nfood
- Thefood.public void addObstacle(Obstacle obstacle)
obstacle
- The new obstacle.public boolean removeObstacle(Obstacle obstacle)
obstacle
- The obstacle.public Creature addCreature(Creature creature)
creature
- The creature.public boolean removeCreature(Creature creature)
creature
- The creature.public void executeStep()
public int getWorldAge()
public int getFoodrate()
public void setFoodrate(int foodrate)
foodrate
- The foodrate.public boolean move(Creature me, String dir)
me
- The creature.dir
- The direction.public Creature[] getCreatures()
public Obstacle[] getObstacles()
public Food[] getFood()
public WorldObject[] getAllObjects()
public int getTaskSize()
public Creature[] getHighscore()
public void saveHighscore()
public void setSaveInterval(long saveinterval)
public long getSaveInterval()
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be added.public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removed.
|
Jadex 0.96 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.