Class Agent


public class Agent extends Message
  • Constructor Details

    • Agent

      public Agent(int maxSteps, Node startNode)
      Constructs and initializes an agent.
      Parameters:
      maxSteps - the maximum number of steps the agent message can take.
  • Method Details

    • move

      protected void move()
      Method to move the agent message to a random neighbour node
      Specified by:
      move in class Message
    • rememberPositions

      protected void rememberPositions()
      Method that removes the current node from stack of previous moves and adds it to array list of previous positions.
      Specified by:
      rememberPositions in class Message
    • getPossibleMoves

      protected ArrayList<Node> getPossibleMoves()
      Method that gets the possible moves for an agent.
      Specified by:
      getPossibleMoves in class Message
      Returns:
      arraylist of the possible moves
    • setCurrentNode

      protected void setCurrentNode(Node node)
      Method that sets a node to current node
      Specified by:
      setCurrentNode in class Message
      Parameters:
      node -
    • getCurrentNode

      public Node getCurrentNode()
      Method that returns the current node for an agent
      Returns:
      current node
    • currentPositionOfAgent

      public Position currentPositionOfAgent()
      Method that returns the position of the agent
      Returns:
      the position of the node that the agent is currently at
    • getPreviousMoves

      public Stack<Node> getPreviousMoves()
      Method that returns a stack of the previous moves for an agent
      Returns:
      a stack of nodes
    • getWaitingQueue

      public Queue<Node> getWaitingQueue()
      Method that returns the waiting queue of nodes
      Returns:
      a queue of nodes
    • addEvent

      public void addEvent(String eventId, Node nextNode, int distance)
      Method that adds events to agents routing table
      Parameters:
      eventId - id string of event
      nextNode - next node to go to
      distance - distance to destination
    • getNumSteps

      public int getNumSteps()
      Returns number of steps that the agent has gone
      Returns:
      number of steps that the agent has gone
    • getMaxSteps

      public int getMaxSteps()
      Returns max steps that agent can go
      Returns:
      max steps that agent can go
    • synchronizeNodesRoutingTable

      public void synchronizeNodesRoutingTable()
      Method that synchronize a nodes routing table with an agent routing table
    • synchronizeAgentsRoutingTable

      public void synchronizeAgentsRoutingTable()
      Method that synchronize an agents routing table with a nodes routing table
    • getRoutingTable

      public HashMap<String,RoutingEntry> getRoutingTable()
      Returns the routing table of the agent.
      Returns:
      the routing table as a HashMap
    • toString

      public String toString()
      Returns agent as a string containing its position, number of steps and routing table.
      Overrides:
      toString in class Object
      Returns:
      agent as a string