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
-
Constructor Summary
ConstructorDescriptioncreates 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 TypeMethodDescriptionvoid
addPercept
(Literal... perceptions) Adds a perception for all agentsvoid
addPercept
(String agName, Literal... per) Adds a perception for a specific agentvoid
Clears all perception (from common list and individual perceptions)void
Clears the list of global perceptsvoid
clearPercepts
(String agName) Clears the list of percepts of a specific agentconsultPercepts
(String agName) Returns a copy of the perception for an agent.boolean
containsPercept
(Literal per) Returns true if the list of common percepts contains the perception per.boolean
containsPercept
(String agName, Literal per) boolean
executeAction
(String agName, Structure act) Executes an action on the environment.getPercepts
(String agName) Returns percepts for an agent.void
informAgsEnvironmentChanged
(String... agents) void
informAgsEnvironmentChanged
(Collection<String> agents) Deprecated.use version with String...void
Called before the MAS execution with the args informed in .mas2j project, the user environment could override it.boolean
boolean
removePercept
(Literal per) Removes a perception from the common perception listboolean
removePercept
(String agName, Literal per) Removes a perception for an agentint
Removes all percepts from the common perception list that unifies with per.int
removePerceptsByUnif
(String agName, Literal per) Removes from an agent perception all percepts that unifies with per.void
scheduleAction
(String agName, Structure action, Object infraData) Called by the agent infrastructure to schedule an action to be executed on the environmentvoid
Sets the infrastructure tier of the environment (saci, jade, local, ...)void
stop()
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.
-