edu.stanford.multiagent.gamer.graphs
Class NDimensionalGrid

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.graphs.Graph
              |
              +--edu.stanford.multiagent.gamer.graphs.ALGraph
                    |
                    +--edu.stanford.multiagent.gamer.graphs.NDimensionalGrid
Direct Known Subclasses:
NDimensionalWrappedGrid

public class NDimensionalGrid
extends ALGraph

Generates a graph on an n-dimensional grid, i.e. 1D is a line, 2D is a regular grid, and so on. Currently all dimensions are the same length to keep parameterization from getting out of hand.


Field Summary
protected static Parameters.ParamInfo[] ndgParam
           
protected static Parameters.ParamInfo pDimSize
           
protected static Parameters.ParamInfo pN
           
 
Fields inherited from class edu.stanford.multiagent.gamer.graphs.ALGraph
nodes
 
Fields inherited from class edu.stanford.multiagent.gamer.graphs.Graph
nEdges, nNodes, nodeData, pReflexEdges, pSymEdges
 
Fields inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
parameters
 
Constructor Summary
NDimensionalGrid()
           
 
Method Summary
protected  void checkParameters()
          Makes sure that the parameters are in the proper range
 void doGenerate()
          Generate an N-dimensional grid graph
protected  java.lang.String getGraphHelp()
          Returns a help information string about the particular graph, does not include parameter information.
 boolean hasSymEdges()
          It is always the case in N-dimensional grids that for every edge a to b there is also an edge b to a
 void initialize()
          Calls graph initialize and also sets up the nodes Vector,
 void randomizeParameters()
          Resets the range of all parameters so that random graph will not be too large to work with most games, then randomize.
 boolean reflexEdgesOk()
          It is never the case in N-dimensional grids that reflexive edges are allowed
protected  int translateIndices(int[] indices, long dimSize, int numDimensions)
          Translate an array of indices into a single integer index of a Vector.
 
Methods inherited from class edu.stanford.multiagent.gamer.graphs.ALGraph
addEdge, addEdge, addNode, areNeighbours, getEdge, getEdges, getNeighbours, getNumNeighbours, removeEdge, removeEdge, setEdgeData
 
Methods inherited from class edu.stanford.multiagent.gamer.graphs.Graph
getHelp, getNEdges, getNNodes, getNodeData, setNodeData
 
Methods inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
getBooleanParameter, getDescription, getDoubleParameter, getLongParameter, getParamDescription, getParameter, getParameters, getStringParameter, setParameter, setParameter, setParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pN

protected static Parameters.ParamInfo pN

pDimSize

protected static Parameters.ParamInfo pDimSize

ndgParam

protected static Parameters.ParamInfo[] ndgParam
Constructor Detail

NDimensionalGrid

public NDimensionalGrid()
                 throws java.lang.Exception
Method Detail

getGraphHelp

protected java.lang.String getGraphHelp()
Description copied from class: Graph
Returns a help information string about the particular graph, does not include parameter information.

Specified by:
getGraphHelp in class Graph

initialize

public void initialize()
                throws java.lang.Exception
Calls graph initialize and also sets up the nodes Vector,

Overrides:
initialize in class Graph
Throws:
java.lang.Exception

randomizeParameters

public void randomizeParameters()
Resets the range of all parameters so that random graph will not be too large to work with most games, then randomize.

Overrides:
randomizeParameters in class ParameterizedObject

checkParameters

protected void checkParameters()
                        throws java.lang.Exception
Makes sure that the parameters are in the proper range

Overrides:
checkParameters in class ALGraph
Throws:
java.lang.Exception - if anything is wrong with the parameter values

translateIndices

protected int translateIndices(int[] indices,
                               long dimSize,
                               int numDimensions)
Translate an array of indices into a single integer index of a Vector. Assumes that each index in the array is between 0 and dimensionSize.


hasSymEdges

public boolean hasSymEdges()
It is always the case in N-dimensional grids that for every edge a to b there is also an edge b to a

Specified by:
hasSymEdges in class Graph

reflexEdgesOk

public boolean reflexEdgesOk()
It is never the case in N-dimensional grids that reflexive edges are allowed

Specified by:
reflexEdgesOk in class Graph

doGenerate

public void doGenerate()
Generate an N-dimensional grid graph

Specified by:
doGenerate in class ParameterizedObject