|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmadkit.kernel.AbstractAgent
warbot.kernel.Brain
public abstract class Brain
The main super class of robot developpers.
This class gives all the avaible primitives that brains can use to control their body.
these methods must be invoked inside the doIt
method.
Some of them represent actions that cost time and energy.
The doIt
method describes what the body has to do in one turn.
Implementation of a robot behavior, by subclassing this Brain
class or by
designing Python or Jess scripts must take care of the following features.
Many actions may be done only once per turn. This is true for instance of the methods: eat
, take
, drop
, launchRocket
, and
buildRocket
.
Only one of these actions may be actually performed per turn, thus calling these methods several times per turn is useless!!
For example :
public void doIt(){ move(); move(); launchRocket(120); }
will only consists in an attempt to launch a rocket in the direction 120. The two move
invocations will be overwritten
by the invocation of the launchRocket
action.
Some methods are only available for a specific type of robot's body.
Only RocketLaunchers may actually
shoot and build rockets. Calling such an action to an Explorer will lead to nothing.
Each type of robot also differs in their speed, initial energy, detecting range.
Information about these attributes may be required with the getter getXXX()
where XXX
is the attribute to be known.
To perceive the world a robot has to ask for the getPercepts
method that returns
an array of Percepts, i.e. an array of objects which are all instance of the
Percept
class. To actually know the type of percept, you must use the
getPerceptType
method that returns a String corresponding to the type of entity.
Here are the percept types and their related entity class:
Obstacle Wall (or PalmTree) Food Hamburger Rocket Rocket Explorer Explorer RocketLauncher RocketLauncher Home Home
See the
Constructor Summary | |
---|---|
Brain()
|
Method Summary | |
---|---|
int |
bagSize()
return the current nb of objects in the robot's bag. |
void |
broadcast(java.lang.String groupName,
java.lang.String roleName,
java.lang.String m)
Sends a WarbotMessage with performative m to all agents with role roleName in group groupName |
void |
broadcast(java.lang.String groupName,
java.lang.String roleName,
java.lang.String m,
java.lang.String a)
Sends a WarbotMessage with performative m and argument a to all agents with role roleName in group groupName |
void |
broadcast(java.lang.String groupName,
java.lang.String roleName,
java.lang.String m,
java.lang.String[] c)
Sends a WarbotMessage with performative m and an array of String arguments c to all agents with role roleName in group groupName |
void |
broadcast(java.lang.String groupName,
java.lang.String roleName,
java.lang.String m,
java.lang.String a1,
java.lang.String a2)
Sends a WarbotMessage with performative m and arguments a1 and a2 to all agents with role roleName in group groupName |
void |
broadcastMessage(java.lang.String groupName,
java.lang.String roleName,
Message m)
In warbot you can only send messages that are instance of the class madkit.messages.StringMessage. |
void |
buildRocket()
try to do the action of building a rocket for future launch. |
void |
createAgent(java.lang.String str)
Tries to create an agent with the available resources. |
double |
distanceTo(Percept p)
returns the distance relative to the perceived entity |
abstract void |
doIt()
This method controls the behavior of a robot. |
void |
drop(int index)
Drop and put in the environment the item that the robot got in its bag. |
void |
dropAll()
Drop and put in the environment everything the robot got in its bag Drop the item if it is possible. |
void |
eat(Food fd)
Try to eat some Food (Food is a percept like everything in warbot world), This action may only be performed once per turn (when the robot is actived), Thus, it is useless to call it several time in the doIt (it will have no effect) |
void |
edit()
|
int |
getBagCapacity()
return the capacity of the robot's bag |
Percept[] |
getBagPercepts()
returns all the things you have in the robot's bag. |
int |
getCoveredDistance()
returns the distance covered for the last unit of time. |
int |
getEnergyLevel()
|
double |
getHeading()
get the robot's current heading |
int |
getMaximumEnergy()
|
Percept[] |
getPercepts()
Gets all the percepts available in the detection range. |
int |
getResourceLevel()
|
int |
getRocketNumber()
how many rocket do the robot currently hold |
boolean |
getShot()
|
java.lang.String |
getTeam()
|
void |
init()
Method invoked just after creation of the Brain and before the activate() method. |
boolean |
isBagEmpty()
return true if the robot's bag if empty. |
boolean |
isBagFull()
return true if the robot's bag if full. |
boolean |
isMoving()
Tells if the robot has moved in the preceding turn or not. |
boolean |
isMyBagEmpty()
|
boolean |
isMyBagFull()
|
boolean |
isShowUserMessage()
|
void |
launchRocket(double direction)
try to do the action of launching a rocket in the desired direction to perform such an action the robot's body must have the ability to launch rockets (like a RocketLauncher) As the action move, it is useless to call this method several time in the doIt: at most just one rocket will be launched. |
void |
move()
Try to move the robot in the world This action may only be performed once per turn (when the robot is actived), Thus, it is useless to call it several time in the doIt (it will have no effect) |
void |
randomHeading()
Give a random direction to the robot |
WarbotMessage |
readMessage()
Reads a message in the message box. |
void |
receiveMessage(Message m)
Put a message into the mailbox and update the relative coordinates of the sender Kernel action, don't invoke this method yourself... |
void |
send(AgentAddress target,
java.lang.String m)
Sends a WarbotMessage with performative m to the target agent |
void |
send(AgentAddress target,
java.lang.String m,
java.lang.String a)
Sends a WarbotMessage with performative m and argument a to the target agent |
void |
send(AgentAddress target,
java.lang.String m,
java.lang.String[] c)
Sends a WarbotMessage with performative m and an array of String arguments c to the target agent |
void |
send(AgentAddress target,
java.lang.String m,
java.lang.String a1,
java.lang.String a2)
Sends a WarbotMessage with performative m and arguments a1 and a2 to the target agent |
void |
sendMessage(AgentAddress target,
Message m)
In warbot you can only send messages that are instance of the class WarbotMessage. |
void |
sendMessage(java.lang.String groupName,
java.lang.String roleName,
Message m)
In warbot you can only send messages that are instance of the class WarbotMessage. |
void |
setHeading(double direction)
set the robot direction, direction |
void |
setUserMessage(java.lang.String s)
|
void |
showUserMessage(boolean b)
|
void |
take(Transportable f)
try to put something in the robot's bag. |
double |
towards(double a,
double b)
returns the direction heading to the relative point a,b |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Brain()
Method Detail |
---|
public void edit()
public void init()
public final double towards(double a, double b)
public double distanceTo(Percept p)
public int getCoveredDistance()
public abstract void doIt()
public void move()
public void eat(Food fd)
public void take(Transportable f)
public java.lang.String getTeam()
public int getEnergyLevel()
public int getMaximumEnergy()
public boolean getShot()
public final void receiveMessage(Message m)
receiveMessage
in class AbstractAgent
public boolean isBagEmpty()
public boolean isMyBagEmpty()
public boolean isBagFull()
public boolean isMyBagFull()
public int bagSize()
public int getBagCapacity()
public Percept[] getBagPercepts()
public void drop(int index)
public void dropAll()
public void createAgent(java.lang.String str)
str,
- the name of the agent to be created as defined in the formalism file..public void launchRocket(double direction)
public void buildRocket()
public int getRocketNumber()
public void setHeading(double direction)
public double getHeading()
public boolean isMoving()
public Percept[] getPercepts()
Percept
public void randomHeading()
public void showUserMessage(boolean b)
public void setUserMessage(java.lang.String s)
public boolean isShowUserMessage()
public int getResourceLevel()
public final WarbotMessage readMessage()
(WarbotMessage) nextMessage()
public final void sendMessage(java.lang.String groupName, java.lang.String roleName, Message m)
sendMessage
in class AbstractAgent
public final void sendMessage(AgentAddress target, Message m)
sendMessage
in class AbstractAgent
target
- AgentAddress of the receiverm
- Message to be sentpublic final void broadcastMessage(java.lang.String groupName, java.lang.String roleName, Message m)
broadcastMessage
in class AbstractAgent
public final void send(AgentAddress target, java.lang.String m)
public final void send(AgentAddress target, java.lang.String m, java.lang.String a)
public final void send(AgentAddress target, java.lang.String m, java.lang.String a1, java.lang.String a2)
public final void send(AgentAddress target, java.lang.String m, java.lang.String[] c)
public final void broadcast(java.lang.String groupName, java.lang.String roleName, java.lang.String m)
public final void broadcast(java.lang.String groupName, java.lang.String roleName, java.lang.String m, java.lang.String a)
public final void broadcast(java.lang.String groupName, java.lang.String roleName, java.lang.String m, java.lang.String a1, java.lang.String a2)
public final void broadcast(java.lang.String groupName, java.lang.String roleName, java.lang.String m, java.lang.String[] c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |