Class InMemoryEnvironment

java.lang.Object
com.tnsai.environment.InMemoryEnvironment
All Implemented Interfaces:
Environment

public final class InMemoryEnvironment extends Object implements Environment
Simple in-memory environment for testing and basic scenarios.

Stores environment state as a key-value map. Useful for unit testing or simple agent simulations.

  • Constructor Details

    • InMemoryEnvironment

      public InMemoryEnvironment(String name)
    • InMemoryEnvironment

      public InMemoryEnvironment(String name, Map<String,Object> initialState)
  • Method Details

    • perceive

      public Percept perceive()
      Description copied from interface: Environment
      Agent perceives the current state of the environment.
      Specified by:
      perceive in interface Environment
      Returns:
      the current percept from the environment
    • act

      public ActionOutcome act(String actionName, Map<String,Object> parameters)
      Description copied from interface: Environment
      Agent acts on the environment.
      Specified by:
      act in interface Environment
      Parameters:
      actionName - the action to perform
      parameters - action parameters
      Returns:
      the outcome of the action
    • onChange

      public void onChange(Consumer<Percept> listener)
      Description copied from interface: Environment
      Registers a listener for environment changes.
      Specified by:
      onChange in interface Environment
      Parameters:
      listener - called when the environment changes
    • getName

      public String getName()
      Description copied from interface: Environment
      Gets the environment name/type.
      Specified by:
      getName in interface Environment
    • getState

      public Map<String,Object> getState()
      Gets the current state directly (for testing).