org.jscience.computing.ai
Class InfluenceMap

java.lang.Object
  extended by org.jscience.computing.ai.InfluenceMap

public class InfluenceMap
extends java.lang.Object

A class encapsulating basic influence mapping functionality.


Field Summary
static int FIRST
          Select the first maximum value.
protected  int[][] influenceMap
          The influence map itself.
static int LAST
          Select the last maximum value.
static int RANDOM
          Select a random maximum value.
protected  double threshold
          The random threshold.
 
Constructor Summary
InfluenceMap()
          Creates a new instance of InfluenceMap
InfluenceMap(int width, int height)
          Create a new instance of InfluenceMap with size information.
 
Method Summary
 int getAt(int x, int y)
          Return the value of the influence map at a given coordinate.
 int getHeight()
          Return the height of the influence map.
 int[] getMaximum(int type)
          Returns the maximum value.
 int getWidth()
          Return the width of the influence map.
 void incrementAt(int x, int y, int increment)
          Increment the influence map by a given increment.
 void reset()
          Resets the influence map to zero (calls resetTo(0))
 void resetTo(int value)
          Resets the influence map to the specified value.
 void setAt(int x, int y, int value)
          Set a point on the influence map to a specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST

public static final int FIRST
Select the first maximum value.

See Also:
Constant Field Values

LAST

public static final int LAST
Select the last maximum value.

See Also:
Constant Field Values

RANDOM

public static final int RANDOM
Select a random maximum value.

See Also:
Constant Field Values

influenceMap

protected int[][] influenceMap
The influence map itself.


threshold

protected double threshold
The random threshold.

Constructor Detail

InfluenceMap

public InfluenceMap()
Creates a new instance of InfluenceMap


InfluenceMap

public InfluenceMap(int width,
                    int height)
Create a new instance of InfluenceMap with size information.

Parameters:
width - the width of the influence map.
height - the height of the influence map.
Method Detail

getWidth

public int getWidth()
Return the width of the influence map.

Returns:
the width.

getHeight

public int getHeight()
Return the height of the influence map.

Returns:
the height.

reset

public void reset()
Resets the influence map to zero (calls resetTo(0))


resetTo

public void resetTo(int value)
Resets the influence map to the specified value.

Parameters:
value - the value to set all positions of the influence map.

setAt

public void setAt(int x,
                  int y,
                  int value)
Set a point on the influence map to a specified value.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
value - the value to set.

getAt

public int getAt(int x,
                 int y)
Return the value of the influence map at a given coordinate.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
Returns:
the value of the influence map.

incrementAt

public void incrementAt(int x,
                        int y,
                        int increment)
Increment the influence map by a given increment. This method can also be used to decrement the influence map.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
increment - the increment to be added (can be negative).

getMaximum

public int[] getMaximum(int type)
Returns the maximum value. Equal values are treated differently according to the type specified: FIRST will return the first maximum value, LAST will return the last, and RANDOM will return a randomly selected maximum position.

Parameters:
type - the selection type.
Returns:
the maximum point. This is returned as an int[3] (x-position, y-position, maximum value).