Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jason.environment
Class Environment

    java.lang.Object
      jason.environment.Environment

Direct Known Subclasses:
  TimeSteppedEnvironment

    public class Environment

extends java.lang.Object

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
`protected java.util.concurrent.ExecutorService` | `executor`

Constructor Summary
`Environment()` creates an environment class with the default number of threads in the pool
`Environment(int n)` creates an environment class with n threads to execute actions required by the agents

Method Summary
`void` | `addPercept(Literal per)` Adds a perception for all agents
`void` | `addPercept(java.lang.String agName, Literal per)` Adds a perception for a specific agent
`void` | `clearPercepts()` Clears the list of global percepts
`void` | `clearPercepts(java.lang.String agName)` Clears the list of percepts of a specific agent
`boolean` | `containsPercept(Literal per)` Returns true if the list of common percepts contains the perception per.
`boolean` | `containsPercept(java.lang.String agName, Literal per)`
`boolean` | `executeAction(java.lang.String agName, Structure act)` Executes an action on the environment.
`EnvironmentInfraTier` | `getEnvironmentInfraTier()`
`java.util.logging.Logger` | `getLogger()`
`java.util.List<Literal>` | `getPercepts(java.lang.String agName)` Returns percepts for an agent.
`void` | `informAgsEnvironmentChanged(java.util.Collection<java.lang.String> agents)` Deprecated. use version with String... parameter
`void` | `informAgsEnvironmentChanged(java.lang.String... agents)`
`void` | `init(java.lang.String[] args)` Called before the MAS execution with the args informed in .mas2j project, the user environment could override it.
`boolean` | `isRunning()`
`boolean` | `removePercept(Literal per)` Removes a perception in the common perception list
`boolean` | `removePercept(java.lang.String agName, Literal per)` Removes a perception for an agent
`int` | `removePerceptsByUnif(Literal per)` Removes all percepts in the common perception list that unifies with per.
`int` | `removePerceptsByUnif(java.lang.String agName, Literal per)` Removes from an agent perception all percepts that unifies with per.
`void` | `scheduleAction(java.lang.String agName, Structure action, java.lang.Object infraData)` Called by the agent infrastructure to schedule an action to be executed on the environment
`void` | `setEnvironmentInfraTier(EnvironmentInfraTier je)` Sets the infrastructure tier of the environment (saci, jade, centralised, ...)
`void` | `stop()` Called just before the end of MAS execution, the user environment could override it.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### executor

    protected java.util.concurrent.ExecutorService executor

Constructor Detail

### 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 Detail

### init

    public void init(java.lang.String[] args)

  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

    public void setEnvironmentInfraTier(EnvironmentInfraTier je)

  Sets the infrastructure tier of the environment (saci, jade, centralised, ...)

### getEnvironmentInfraTier

    public EnvironmentInfraTier getEnvironmentInfraTier()

### getLogger

    public java.util.logging.Logger getLogger()

### informAgsEnvironmentChanged

    public void informAgsEnvironmentChanged(java.util.Collection<java.lang.String> agents)

  Deprecated. use version with String... parameter

### informAgsEnvironmentChanged

    public void informAgsEnvironmentChanged(java.lang.String... agents)

### getPercepts

    public java.util.List<Literal> getPercepts(java.lang.String agName)

  Returns percepts for an agent. A full copy of both common and agent's percepts lists is returned.

### addPercept

    public void addPercept(Literal per)

  Adds a perception for all agents

### removePercept

    public boolean removePercept(Literal per)

  Removes a perception in the common perception list

### removePerceptsByUnif

    public int removePerceptsByUnif(Literal per)

  Removes all percepts in 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

    public boolean containsPercept(Literal per)

  Returns true if the list of common percepts contains the perception per.

### addPercept

    public void addPercept(java.lang.String agName,
                           Literal per)

  Adds a perception for a specific agent

### removePercept

    public boolean removePercept(java.lang.String agName,
                                 Literal per)

  Removes a perception for an agent

### removePerceptsByUnif

    public int removePerceptsByUnif(java.lang.String agName,
                                    Literal per)

  Removes from an agent perception all percepts that unifies with per.

  Returns:
    the number of removed percepts.

### containsPercept

    public boolean containsPercept(java.lang.String agName,
                                   Literal per)

### clearPercepts

    public void clearPercepts(java.lang.String agName)

  Clears the list of percepts of a specific agent

### scheduleAction

    public void scheduleAction(java.lang.String agName,
                               Structure action,
                               java.lang.Object infraData)

  Called by the agent infrastructure to schedule an action to be executed on the environment

### executeAction

    public boolean executeAction(java.lang.String agName,
                                 Structure act)

  Executes an action on the environment. This method is probably overridden in the user environment class.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD