|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmassim.javaagents.Agent
public abstract class Agent
This class represents a simple agent. Note that is is an abstract class, that is that you are supposed to inherit from this class in order to implement specialized agents.
An abstract agent consists of beliefs and goals and has access to a simple system for communicating with others. Note that specialized agents can and will be instantiated by the interpreter using Java-reflection.
Field Summary | |
---|---|
protected java.util.Set<apltk.interpreter.data.LogicGoal> |
goals
|
Constructor Summary | |
---|---|
Agent(java.lang.String name,
java.lang.String team)
Initializes an agent with a given name. |
Method Summary | |
---|---|
void |
addBelief(apltk.interpreter.data.LogicBelief belief)
|
void |
addGoal(apltk.interpreter.data.LogicGoal goal)
|
void |
broadcastBelief(apltk.interpreter.data.LogicBelief belief)
Sends a message to all agents of the team. |
protected void |
clearBeliefs()
|
void |
clearGoals()
|
boolean |
containsBelief(apltk.interpreter.data.LogicBelief belief)
|
protected boolean |
containsGoal(apltk.interpreter.data.LogicGoal goal)
|
static Agent |
createAgentFromClass(java.lang.String agentName,
java.lang.String team,
java.lang.String agentClass)
Yields an instance of a specified agent-class with a given name. |
boolean |
equals(java.lang.Object obj)
|
java.util.LinkedList<apltk.interpreter.data.LogicBelief> |
getAllBeliefs(java.lang.String predicate)
Yields all beliefs from the belief base that have a specific predicate. |
protected java.util.Collection<eis.iilang.Percept> |
getAllPercepts()
Yields all percepts that are currently available. |
java.util.Collection<apltk.interpreter.data.LogicBelief> |
getBeliefBase()
Yields the belief-base of the agent. |
static eis.EnvironmentInterfaceStandard |
getEnvironmentInterface()
Yields the environment-interface that all agents access. |
java.util.Collection<apltk.interpreter.data.LogicGoal> |
getGoalBase()
Yields the goal-base of the agent. |
protected java.util.Collection<apltk.interpreter.data.Message> |
getMessages()
Gets all messages that were sent to the agent. |
java.lang.String |
getName()
Yields the name of the agent. |
java.lang.String |
getTeam()
Yields the team of the agent. |
abstract void |
handlePercept(eis.iilang.Percept p)
This method is called if the environment-interface sends a percept as a notification. |
int |
hashCode()
|
protected void |
println(java.lang.Object obj)
Prints an arbitrary object, e.g. a String, to the standard-out. |
void |
removeBeliefs(java.lang.String predicate)
Removes all beliefs from the belief-base that have a given predicate. |
protected void |
removeGoals(java.lang.String predicate)
Removes all goals that have a given predicate. |
void |
sendMessage(apltk.interpreter.data.Belief belief,
java.lang.String receiver)
Sends a message to a specific agent in the team. |
static void |
setEnvironmentInterface(eis.EnvironmentInterfaceStandard theEI)
Sets the environment-interface for all agents in this process. |
abstract eis.iilang.Action |
step()
Executes one step of the agent. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Set<apltk.interpreter.data.LogicGoal> goals
Constructor Detail |
---|
public Agent(java.lang.String name, java.lang.String team)
name
- is the name of the agentteam
- is the team of the agentMethod Detail |
---|
public java.lang.String getName()
public java.lang.String getTeam()
public static Agent createAgentFromClass(java.lang.String agentName, java.lang.String team, java.lang.String agentClass)
agentName
- is the name of the agentteam
- is the team of the agentagentClass
- is the fully-qualified name of the agent-class to-be-loaded
public static void setEnvironmentInterface(eis.EnvironmentInterfaceStandard theEI)
theEI
- is the environment-interfacepublic static eis.EnvironmentInterfaceStandard getEnvironmentInterface()
public abstract eis.iilang.Action step()
protected final void println(java.lang.Object obj)
obj
- public final java.util.Collection<apltk.interpreter.data.LogicBelief> getBeliefBase()
public final java.util.Collection<apltk.interpreter.data.LogicGoal> getGoalBase()
protected java.util.Collection<eis.iilang.Percept> getAllPercepts()
protected final java.util.Collection<apltk.interpreter.data.Message> getMessages()
public final void sendMessage(apltk.interpreter.data.Belief belief, java.lang.String receiver)
msg
- the message to be sentreceiver
- the recipient of the messagepublic final void broadcastBelief(apltk.interpreter.data.LogicBelief belief)
msg
- the message to be broadcastedpublic abstract void handlePercept(eis.iilang.Percept p)
getAllPercepts
method which
yields all percepts.
p
- the percept to be handledpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.LinkedList<apltk.interpreter.data.LogicBelief> getAllBeliefs(java.lang.String predicate)
predicate
- the given predicate
public void removeBeliefs(java.lang.String predicate)
predicate
- the given predicateprotected void removeGoals(java.lang.String predicate)
predicate
- the given predicatepublic void addBelief(apltk.interpreter.data.LogicBelief belief)
public void addGoal(apltk.interpreter.data.LogicGoal goal)
public boolean containsBelief(apltk.interpreter.data.LogicBelief belief)
protected boolean containsGoal(apltk.interpreter.data.LogicGoal goal)
protected void clearBeliefs()
public void clearGoals()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |