Package jason.environment
Class Environment
java.lang.Object
jason.environment.Environment
- Direct Known Subclasses:
TimeSteppedEnvironment
It is a base class for Environment, it is overridden by the user
application to define the environment "behaviour".
Execution sequence:
- setEnvironmentInfraTier,
- init,
- (getPercept|executeAction)*,
- stop.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptioncreates an environment class with the default number of threads in the poolEnvironment(int n) creates an environment class with n threads to execute actions required by the agents -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPercept(Literal... perceptions) Adds a perception for all agentsvoidaddPercept(String agName, Literal... per) Adds a perception for a specific agentvoidClears all perception (from common list and individual perceptions)voidClears the list of global perceptsvoidclearPercepts(String agName) Clears the list of percepts of a specific agentconsultPercepts(String agName) Returns a copy of the perception for an agent.booleancontainsPercept(Literal per) Returns true if the list of common percepts contains the perception per.booleancontainsPercept(String agName, Literal per) booleanexecuteAction(String agName, Structure act) Executes an action on the environment.getPercepts(String agName) Returns percepts for an agent.voidinformAgsEnvironmentChanged(String... agents) voidinformAgsEnvironmentChanged(Collection<String> agents) Deprecated.use version with String...voidCalled before the MAS execution with the args informed in .mas2j project, the user environment could override it.booleanbooleanremovePercept(Literal per) Removes a perception from the common perception listbooleanremovePercept(String agName, Literal per) Removes a perception for an agentintRemoves all percepts from the common perception list that unifies with per.intremovePerceptsByUnif(String agName, Literal per) Removes from an agent perception all percepts that unifies with per.voidscheduleAction(String agName, Structure action, Object infraData) Called by the agent infrastructure to schedule an action to be executed on the environmentvoidSets the infrastructure tier of the environment (saci, jade, local, ...)voidstop()Called just before the end of MAS execution, the user environment could override it.
-
Field Details
-
executor
-
-
Constructor Details
-
Environment
public Environment(int n) creates an environment class with n threads to execute actions required by the agents -
Environment
public Environment()creates an environment class with the default number of threads in the pool
-
-
Method Details
-
init
Called before the MAS execution with the args informed in .mas2j project, the user environment could override it. -
stop
public void stop()Called just before the end of MAS execution, the user environment could override it. -
isRunning
public boolean isRunning() -
setEnvironmentInfraTier
Sets the infrastructure tier of the environment (saci, jade, local, ...) -
getEnvironmentInfraTier
-
getLogger
-
informAgsEnvironmentChanged
Deprecated.use version with String... parameter -
informAgsEnvironmentChanged
-
getPercepts
Returns percepts for an agent. A full copy of both common and agent's percepts lists is returned. It returns null if the agent's perception doesn't changed since last call. This method is to be called by TS and should not be called by other objects. -
consultPercepts
Returns a copy of the perception for an agent. It is the same list returned by getPercepts, but doesn't consider the last call of the method. -
addPercept
Adds a perception for all agents -
removePercept
Removes a perception from the common perception list -
removePerceptsByUnif
Removes all percepts from the common perception list that unifies with per. Example: removePerceptsByUnif(Literal.parseLiteral("position(_)")) will remove all percepts that unifies "position(_)".- Returns:
- the number of removed percepts.
-
clearPercepts
public void clearPercepts()Clears the list of global percepts -
containsPercept
Returns true if the list of common percepts contains the perception per. -
addPercept
Adds a perception for a specific agent -
removePercept
Removes a perception for an agent -
removePerceptsByUnif
Removes from an agent perception all percepts that unifies with per.- Returns:
- the number of removed percepts.
-
containsPercept
-
clearPercepts
Clears the list of percepts of a specific agent -
clearAllPercepts
public void clearAllPercepts()Clears all perception (from common list and individual perceptions) -
scheduleAction
Called by the agent infrastructure to schedule an action to be executed on the environment -
executeAction
Executes an action on the environment. This method is probably overridden in the user environment class.
-