ou3
Class Map

java.lang.Object
  extended by ou3.Map

public class Map
extends java.lang.Object

A map consisting of a matrix of nodes.

Author:
tm11ajn

Field Summary
private  int agentMaxSteps
          The maximum amount of steps an Agent is allowed to take.
private  double agentProbability
          A number representing the probability of an Agent being created.
private  java.util.ArrayList<java.util.ArrayList<Node>> nodeList
          Contains all nodes in the map.
private  int nOfEvents
          The number of events detected in the map.
private  int nOfRequestNodes
          The number of nodes designated to create requests.
private  int requestMaxSteps
          The maximum amount of steps an Request is allowed to take.
private  java.util.ArrayList<Node> requestNodes
          Contains the request nodes.
private  int time
          The amount of timesteps taken by the map
private  int xSize
          The width of the map
private  int ySize
          The height of the map
 
Constructor Summary
Map(int xSize, int ySize)
          Creates a map.
 
Method Summary
private  java.util.ArrayList<java.util.ArrayList<Node>> createNodeList()
          Returns an array of nodes.
private  void createRequest()
          Creates a request in the four request nodes and randomizes what event the requests will be searching for.
private  void detectEvents()
          Detects if any events are created.
 java.util.ArrayList<Node> getNeighbours(Position pos)
          Returns the neighbours of a node given its position.
private  java.util.ArrayList<Node> getRequestNodes()
          Selects four random nodes from the nodeList and returns an ArrayList containing them.
 int tick()
          Advances all the nodes on the map a timestep and detects if any events are created.
private  void tickNodes()
          Advances all the nodes on the map a timestep.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeList

private java.util.ArrayList<java.util.ArrayList<Node>> nodeList
Contains all nodes in the map.


time

private int time
The amount of timesteps taken by the map


xSize

private int xSize
The width of the map


ySize

private int ySize
The height of the map


nOfEvents

private int nOfEvents
The number of events detected in the map.


nOfRequestNodes

private final int nOfRequestNodes
The number of nodes designated to create requests.


requestNodes

private java.util.ArrayList<Node> requestNodes
Contains the request nodes.


agentProbability

private final double agentProbability
A number representing the probability of an Agent being created.


agentMaxSteps

private final int agentMaxSteps
The maximum amount of steps an Agent is allowed to take.


requestMaxSteps

private final int requestMaxSteps
The maximum amount of steps an Request is allowed to take.

Constructor Detail

Map

public Map(int xSize,
           int ySize)
Creates a map.

Parameters:
int - xSize
int - ySize
Method Detail

createNodeList

private java.util.ArrayList<java.util.ArrayList<Node>> createNodeList()
Returns an array of nodes.

Returns:
ArrayList>

getRequestNodes

private java.util.ArrayList<Node> getRequestNodes()
Selects four random nodes from the nodeList and returns an ArrayList containing them.

Returns:
ArrayList tempList

getNeighbours

public java.util.ArrayList<Node> getNeighbours(Position pos)
                                        throws java.lang.IndexOutOfBoundsException
Returns the neighbours of a node given its position.

Parameters:
Position - pos
Returns:
ArrayList neighbours
Throws:
java.lang.Exception
java.lang.IndexOutOfBoundsException

tick

public int tick()
Advances all the nodes on the map a timestep and detects if any events are created.

Returns:
int time

detectEvents

private void detectEvents()
Detects if any events are created. The probability than an event will be detected is 0.01% (that is, 1 in 10000) per node in the map.


createRequest

private void createRequest()
Creates a request in the four request nodes and randomizes what event the requests will be searching for.


tickNodes

private void tickNodes()
Advances all the nodes on the map a timestep.