Package astra.lang

Class System


  • public class System
    extends Module
    The System API contains a number of actions, terms and formulae that help you to manage the operation of the overall multi-agent system.
    • Constructor Detail

      • System

        public System()
    • Method Detail

      • skip

        public boolean skip()
      • setAgent

        public void setAgent​(Agent agent)
        This internal method associates the agent with the module - this is overridden to store a reference to the agent in the agents map
        Overrides:
        setAgent in class Module
      • fail

        public boolean fail()
        Action that fails.
        Returns:
        false
      • terminate

        public boolean terminate()
        Action that allows the agent to terminate itself.
        Returns:
        true if the action succeeds, false otherwise
      • createAgent

        public boolean createAgent​(String name,
                                   String clazz)
        Action that allows the agent to create another agent.
        Parameters:
        name - the name of the agent to be created
        clazz - the class of the agent (an ASTRA class)
        Returns:
        true if the action succeeds, false otherwise
      • setMainGoal

        public boolean setMainGoal​(String name,
                                   ListTerm args)
        This method can be used to set the main goal of an agent. It has been added to support the basic debugger...
        Parameters:
        name - the name of the agent
        args - the list of arguments to be passed with the goal
        Returns:
        true if the action succeeds, false otherwise
      • terminateAgent

        public boolean terminateAgent​(String name)
        Action to terminate another agent (if it exists and the invoking agent is the owner of that agent).
        Parameters:
        name - the name of the agent to be terminated
        Returns:
        true if the action succeeds, false otherwise
      • getAgents

        public ListTerm getAgents()
        Term that returns a list of all the agents on the platform.
        Returns:
        an ASTRA list containing the names of all agents on the platform
      • getType

        public String getType()
        Term that returns the type of the agent.
        Returns:
        the type of the agent
      • addEvent

        public boolean addEvent​(Event event)
      • addRule

        public boolean addRule​(Rule rule)
      • agentRules

        public ListTerm agentRules()
      • getType

        public String getType​(String name)
        Term that returns the type of the agent with the given name.
        Parameters:
        name - the name of the agent
        Returns:
        the type of the agent with the given name
      • getAgentsOfType

        public ListTerm getAgentsOfType​(String type)
        Term that returns a list of all the agents on the platform
        Parameters:
        type - the agent type
        Returns:
        an ASTRA list containing the names of all agents on the platform
      • getChildren

        public ListTerm getChildren()
        Term that returns a list of all the agents on that are children of the invoking agent
        Returns:
        an ASTRA list containing the names of all agents on the platform
      • getOwner

        public String getOwner()
        Term that returns a list of all the agents on that are children of the invoking agent
        Returns:
        an ASTRA list containing the names of all agents on the platform
      • hasType

        public Formula hasType​(String type)
        Formula thet returns true if the given type is available on the agent platform
        Parameters:
        type - the agent type
        Returns:
        the formula TRUE if the type exists on the agent platform, the formula FALSE otherwise
      • hasChildren

        public Formula hasChildren()
        Formula that returns true if the agent has children (i.e. it has created other agents), false otherwise.
        Returns:
        the formula TRUE if the agent has children, the formula FALSE otherwise
      • hasOwner

        public Formula hasOwner()
        Formula that returns true if the agent has an owner, false otherwise (this will only return false for the "main" agent.
        Returns:
        the formula TRUE if the agent has an owner, the formula FALSE otherwise
      • exit

        public boolean exit()
        Action that causes the platform to stop
        Returns:
        true if the action succeeds, false otherwise
      • sleep

        public boolean sleep​(int time)
        Action that causes the agent to sleep for a specified period of time
        Parameters:
        time - the sleep time in milliseconds
        Returns:
        true if the action succeeds, false otherwise
      • name

        public String name()
        Term that returns the name of the agent.
        Returns:
        the name of the agent
      • setSchedulePoolSize

        public boolean setSchedulePoolSize​(int size)
      • setSchedulingStrategy

        public boolean setSchedulingStrategy​(String strategy)
        Action that allows you to set the scheduling strategy used by the agents...
        Parameters:
        strategy - a fully qualified SchedulerStrategy class name
        Returns:
        true if the action succeeds, false otherwise
      • currentTimeMillis

        public long currentTimeMillis()
        Term that returns the current time in millisecond (delegates to the System class)
        Returns:
        the current time in milliseconds
      • agentExists

        public Formula agentExists​(String name)
        Formula that returns true if the agent exists, false otherwise.
        Parameters:
        name - the name of the agent being checked
        Returns:
        the formula TRUE if the agent exists, FALSE otherwise
      • deconstruct

        public AgentState deconstruct​(String name)
        Term that captures the current state of the specified agent through serialisation of its beliefs and stores that state in an AgentState object.
        Parameters:
        name - the name of the agent whose state is to be captured.
        Returns:
        an object representing the state of the agent
      • reconstruct

        public boolean reconstruct​(AgentState state)
        Action that recreates an agent based on the given state, which is passed in as an instance of the AgentState class.
        Parameters:
        state - the state of the agent to be recreated.
        Returns:
        true if the action succeeeds, false otherwise
      • getNameFromState

        public String getNameFromState​(AgentState state)
        Term that extracts the name of the agent from an AgentState object.
        Parameters:
        state - an agent state
        Returns:
        the name of the agent as recorded in the state representation
      • setSleepTime

        public boolean setSleepTime​(long time)
        Sets the sleep time for the scheduler.
        Parameters:
        time - a duration in milliseconds (ms)
        Returns:
        true if the action succeeeds, false otherwise
      • displayTimings

        public boolean displayTimings()
        Displays the agent timings table
        Returns:
        true if the action succeeds, false otherwise
      • trace

        public boolean trace​(boolean trace)
      • step

        public boolean step()