Class SimpleState

java.lang.Object
nl.uu.cs.aplib.mainConcepts.SimpleState
Direct Known Subclasses:
DumbDoctor.DoctorBelief, GuessNumberGame.MyAgentState, State, Test_BasicAgent_budgeting.MyState, Test_BasicAgent.MyState, Test_DynamicGoalStructure.MyState, Test_Tactic.IntState

public class SimpleState extends Object
This class is the root class for representing agents' states (an 'agent' is an instance of BasicAgent or its subclasses). For most uses, you will need to extend/subclass this class to enable your agents to track whatever domain specific information that your agents need to track.

An instance of this class represents the semantical part of an agent's state. By 'semantical' we mean that the instance is intended to contain information that is relevant for solving the agent's goals. In particular, instances of this class do not expose information relevant only for the agent's internal control of its execution. The latter information is, and should be, hidden from you.

As the root class, an instance of this class actually contains no domain specific semantical information. This may sound contradictive with what we just said above, but this is actually reasonable: there is no way to know upfront what kind of problems you want to solve with agents, therefore we cannot provide none either. If you need information that the agent should track, you need to extend this class to introduce the needed fields to hold that information. The exception to this is the following. Any instance S of this class does get the following:

  1. A message queue containing incoming messages (instances of nl.uu.cs.aplib.multiAgentSupport) for the agent that owns S. The queue itself is not exposed. Instead, the agent can access it through a number of exposed methods, e.g. to check if a message of a certain type is present in the queue and to pop it out.
  2. A pointer to the Environment used by the agent, thus allowing the agent to inspect the Environment, and to send commands to it.
Author:
wish
  • Field Details

  • Constructor Details

    • SimpleState

      public SimpleState()
  • Method Details

    • setEnvironment

      public SimpleState setEnvironment(Environment env)
      Every instance of this class requires an instance to the Environment that is used by the agent that owns this state. This methods allows you to set this state's pointer to the given environment.
      Parameters:
      env - The Environment we want to associate with this state.
      Returns:
      The method simply returns this state to allow it to be used in the Fluent Interface style.
    • updateState

      public void updateState(String agentId)
      This method should send an observe() command to the Environment (that is attached to this state) to send back a new observation from the perspective of the specified agent. This method subsequently uses this fresh observation to update itself.

      Since this SimpleState does not actually has any state information, being just a 'simple' state, this method updateState() does not actually update anything. Override this method to implement a more elaborate scheme of updating state.

    • env

      public Environment env()
      Return the Environment associated with the state.
    • owner

      public BasicAgent owner()
    • log

      protected void log(Level level, String s)
      Write the string to the logger attached to this state, with the specified logging level.