Class Agent
java.lang.Object
Message
Agent
-
Field Summary
Fields inherited from class Message
currentNode, maxSteps, numSteps, previousMoves, previousPositions, waitingQueue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod that adds events to agents routing tableMethod that returns the position of the agentMethod that returns the current node for an agentintReturns max steps that agent can gointReturns number of steps that the agent has goneMethod that gets the possible moves for an agent.Method that returns a stack of the previous moves for an agentReturns the routing table of the agent.Method that returns the waiting queue of nodesprotected voidmove()Method to move the agent message to a random neighbour nodeprotected voidMethod that removes the current node from stack of previous moves and adds it to array list of previous positions.protected voidsetCurrentNode(Node node) Method that sets a node to current nodevoidMethod that synchronize an agents routing table with a nodes routing tablevoidMethod that synchronize a nodes routing table with an agent routing tabletoString()Returns agent as a string containing its position, number of steps and routing table.
-
Constructor Details
-
Agent
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 -
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:
rememberPositionsin classMessage
-
getPossibleMoves
Method that gets the possible moves for an agent.- Specified by:
getPossibleMovesin classMessage- Returns:
- arraylist of the possible moves
-
setCurrentNode
Method that sets a node to current node- Specified by:
setCurrentNodein classMessage- Parameters:
node-
-
getCurrentNode
Method that returns the current node for an agent- Returns:
- current node
-
currentPositionOfAgent
Method that returns the position of the agent- Returns:
- the position of the node that the agent is currently at
-
getPreviousMoves
Method that returns a stack of the previous moves for an agent- Returns:
- a stack of nodes
-
getWaitingQueue
Method that returns the waiting queue of nodes- Returns:
- a queue of nodes
-
addEvent
Method that adds events to agents routing table- Parameters:
eventId- id string of eventnextNode- next node to go todistance- 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
Returns the routing table of the agent.- Returns:
- the routing table as a HashMap
-
toString
Returns agent as a string containing its position, number of steps and routing table.
-