warbot.kernel
Class BasicBody

java.lang.Object
  extended bySNode
      extended bywarbot.kernel.Entity
          extended bywarbot.kernel.MovableEntity
              extended bywarbot.kernel.BasicBody
All Implemented Interfaces:
Body, Serializable
Direct Known Subclasses:
Explorer, Home, RocketLauncher

public abstract class BasicBody
extends MovableEntity
implements Body

The abstract body class. All brain are linked to a subclass of it

Version:
0.1
Author:
Fabien Michel
See Also:
Serialized Form

Field Summary
static String[] ACTIONS
           
static int BAG_CAPACITY
           
protected  String behaviorFileName
           
protected  String brainClass
           
static int DISTANCE_TO_EAT
           
static int DISTANCE_TO_TAKE
           
protected static int DROP
           
protected static int DROPALL
           
protected static int EAT
           
protected  int maximumEnergy
           
protected static int TAKE
           
 
Fields inherited from class warbot.kernel.MovableEntity
MOVE
 
Fields inherited from class warbot.kernel.Entity
action, actionIn, detectingRange, displaySize, energy, initialEnergy, NULL, radius, showDetect, showEnergyLevel, speed, x, xdisplay, y, ydisplay
 
Method Summary
 void buildRocket()
          try to do the action of building a rocket for future launch
 void createAgent(String type)
           
 void createDefaultImage()
           
 void delete()
           
 void die()
          suicide
 void drop(int index)
          try to put something out of the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt
 void dropAll()
          try to put everything out of the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt
 void eat(Food f)
           
 void edit()
           
 int getBagCapacity()
          return the capacity of the robot's bag.
 String getBehaviorFileName()
          Return the behavior file name attached to the brain class used for scripting.
 String getBrainClass()
          Get the brain class name of an entity which generally derives from AbstractAgent.
 double getCoveredDistance()
          returns the distance covered during the last time unit.
 int getEnergy()
          return the current energy of the robot
 double getHeading()
          get the robot's current heading
 int getMaximumEnergy()
           
 Percept[] getPercepts()
          return all the percepts avaible within the detecetion range. you have to use the getPerceptType method of an object Percept to know the kind (class) of one percept
 int getRadius()
           
 int getResourceLevel()
           
 int getRocketNb()
           
 boolean getShot()
           
 String getTeam()
          return the current team as a String Object
 String getUserMessage()
           
protected  void increaseEnergyLevel(int v)
           
 void init()
           
 Percept[] inMyBag()
           
 boolean isMyBagEmpty()
          return true if the robot's bag if empty.
 boolean isMyBagFull()
          return true if the robot's bag if full.
 boolean isShowMessages()
           
 boolean isShowUserMessage()
           
 void launchRocket(double direction)
          try to do the action of launching a rocket in the direction wanted to do this kind of action you have to be rocket launcher, this is done by play the role of rocket launcher.
 void makeBrain(String className, String name, boolean gui, String behaviorFileName)
          Creates the brain and launches if it is an agent.
 Percept makePercept(double dx, double dy, double d)
           
 void move()
          try to do the action of move in the world you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt
 boolean moving()
           
 int nbOfObjectsInMyBag()
          return the current nb of objects in the robot's bag.
 void setBehaviorFileName(String s)
          Set the behavior file name attached to the brain class used for scripting the behavior.
 void setBrainClass(String s)
          set the brain class name of an entity.
 void setHeading(double direction)
          set the robot heading to the direction of value
protected  void setPercepts(Percept[] plst)
           
 void setShowMessages(boolean b)
           
 void setShowUserMessage(boolean b)
           
 void setUserMessage(String s)
           
 void take(Transportable p)
          try to put something in the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt
 void toggleShowMessages()
           
 void toggleShowUserMessage()
           
protected  void tryEat()
           
 
Methods inherited from class warbot.kernel.MovableEntity
tryMove
 
Methods inherited from class warbot.kernel.Entity
addInArrow, addOutArrow, decreaseEnergyLevel, distanceFrom, dropEntity, getDetectingRange, getEnvironmentAgent, getInArrows, getName, getOutArrows, getShowDetect, getShowEnergyLevel, getSpeed, getX, getY, isConnectable, setDetectingRange, setEnergy, setEnvironmentAgent, setName, setRadius, setShowDetect, setShowEnergyLevel, setSpeed, setTeam, setX, setY, toggleShowDetect, toggleShowEnergyLevel, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DISTANCE_TO_TAKE

public static final int DISTANCE_TO_TAKE
See Also:
Constant Field Values

DISTANCE_TO_EAT

public static final int DISTANCE_TO_EAT
See Also:
Constant Field Values

maximumEnergy

protected int maximumEnergy

EAT

protected static final int EAT
See Also:
Constant Field Values

TAKE

protected static final int TAKE
See Also:
Constant Field Values

DROP

protected static final int DROP
See Also:
Constant Field Values

DROPALL

protected static final int DROPALL
See Also:
Constant Field Values

ACTIONS

public static final String[] ACTIONS

BAG_CAPACITY

public static final int BAG_CAPACITY
See Also:
Constant Field Values

brainClass

protected String brainClass

behaviorFileName

protected String behaviorFileName
Method Detail

makePercept

public Percept makePercept(double dx,
                           double dy,
                           double d)
Overrides:
makePercept in class Entity

createDefaultImage

public void createDefaultImage()
Specified by:
createDefaultImage in interface Body

setShowMessages

public void setShowMessages(boolean b)

isShowMessages

public boolean isShowMessages()

toggleShowMessages

public void toggleShowMessages()

setBrainClass

public void setBrainClass(String s)
set the brain class name of an entity. The brain generally derives from AbstractAgent.


getBrainClass

public String getBrainClass()
Get the brain class name of an entity which generally derives from AbstractAgent.


setBehaviorFileName

public void setBehaviorFileName(String s)
Set the behavior file name attached to the brain class used for scripting the behavior.


getBehaviorFileName

public String getBehaviorFileName()
Return the behavior file name attached to the brain class used for scripting.


makeBrain

public void makeBrain(String className,
                      String name,
                      boolean gui,
                      String behaviorFileName)
Creates the brain and launches if it is an agent. The brain class is given as a String. The name argument is used to instantiate the name of the corresponding agent. If the gui flag is true, a bean is created and associated to this agent.


init

public void init()
Overrides:
init in class Entity

setShowUserMessage

public void setShowUserMessage(boolean b)
Specified by:
setShowUserMessage in interface Body

isShowUserMessage

public boolean isShowUserMessage()
Specified by:
isShowUserMessage in interface Body

toggleShowUserMessage

public void toggleShowUserMessage()

setUserMessage

public void setUserMessage(String s)
Specified by:
setUserMessage in interface Body

getUserMessage

public String getUserMessage()

delete

public final void delete()
Overrides:
delete in class Entity

edit

public void edit()

die

public final void die()
Description copied from interface: Body
suicide

Specified by:
die in interface Body

setPercepts

protected void setPercepts(Percept[] plst)

getPercepts

public Percept[] getPercepts()
Description copied from interface: Body
return all the percepts avaible within the detecetion range. you have to use the getPerceptType method of an object Percept to know the kind (class) of one percept

Specified by:
getPercepts in interface Body

move

public void move()
Description copied from interface: Body
try to do the action of move in the world you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt

Specified by:
move in interface Body

eat

public void eat(Food f)
Specified by:
eat in interface Body

getMaximumEnergy

public int getMaximumEnergy()
Specified by:
getMaximumEnergy in interface Body

getResourceLevel

public int getResourceLevel()
Specified by:
getResourceLevel in interface Body

tryEat

protected void tryEat()

increaseEnergyLevel

protected void increaseEnergyLevel(int v)
Overrides:
increaseEnergyLevel in class Entity

take

public void take(Transportable p)
Description copied from interface: Body
try to put something in the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt

Specified by:
take in interface Body

inMyBag

public Percept[] inMyBag()
Specified by:
inMyBag in interface Body

isMyBagEmpty

public boolean isMyBagEmpty()
Description copied from interface: Body
return true if the robot's bag if empty.

Specified by:
isMyBagEmpty in interface Body

isMyBagFull

public boolean isMyBagFull()
Description copied from interface: Body
return true if the robot's bag if full.

Specified by:
isMyBagFull in interface Body

getBagCapacity

public int getBagCapacity()
Description copied from interface: Body
return the capacity of the robot's bag.

Specified by:
getBagCapacity in interface Body

nbOfObjectsInMyBag

public int nbOfObjectsInMyBag()
Description copied from interface: Body
return the current nb of objects in the robot's bag.

Specified by:
nbOfObjectsInMyBag in interface Body

drop

public void drop(int index)
Description copied from interface: Body
try to put something out of the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt

Specified by:
drop in interface Body

dropAll

public void dropAll()
Description copied from interface: Body
try to put everything out of the robot's bag. you can do this action only one time per turn (when the robot is actived), so it is useless to call it several time in the doIt

Specified by:
dropAll in interface Body

launchRocket

public void launchRocket(double direction)
Description copied from interface: Body
try to do the action of launching a rocket in the direction wanted to do this kind of action you have to be rocket launcher, this is done by play the role of rocket launcher. As the action move, it is useless to call this method several time in the doIt: at most just one rocket will be launched

Specified by:
launchRocket in interface Body

buildRocket

public void buildRocket()
try to do the action of building a rocket for future launch

Specified by:
buildRocket in interface Body

getRocketNb

public int getRocketNb()
Specified by:
getRocketNb in interface Body

createAgent

public void createAgent(String type)
Specified by:
createAgent in interface Body

setHeading

public void setHeading(double direction)
set the robot heading to the direction of value


getHeading

public double getHeading()
get the robot's current heading


getTeam

public String getTeam()
return the current team as a String Object


getCoveredDistance

public double getCoveredDistance()
returns the distance covered during the last time unit. This method may be called to sum the path taken by agents.


getEnergy

public int getEnergy()
return the current energy of the robot


getShot

public boolean getShot()

moving

public boolean moving()

getRadius

public int getRadius()


Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.