|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.udo.cs.ie.cowbots.util.DistanceMap
public class DistanceMap
this class models a distance map that is used to evaluate the distance between cells on a tileworld.
Nested Class Summary | |
---|---|
(package private) class |
DistanceMap.FillStart
internal used helper class for next fill point |
Field Summary | |
---|---|
(package private) int[][] |
attrib
|
(package private) int[] |
bestSearches
|
(package private) static byte |
BIT_ATSWITCH
|
(package private) static byte |
BIT_OBSTACLE
|
(package private) int |
borderGuard
|
(package private) int |
fillX
|
(package private) int |
fillY
|
(package private) int |
height
|
(package private) int[][] |
map
|
(package private) int[][] |
penalty
|
(package private) int[] |
penSearches
|
(package private) static java.lang.String[] |
relDir
|
(package private) static int[] |
relX
|
(package private) static int[] |
relY
|
(package private) int |
width
|
Constructor Summary | |
---|---|
DistanceMap(int x,
int y)
creates a distance map |
Method Summary | |
---|---|
void |
debugPrint()
debug output to console |
int |
distance(int x,
int y)
returns the distance from a point to the distance maps reference point. the meaning of the return values is: 0 : no path exists to the fill point 1 : same field >1 : distance to fill point |
void |
fill(int sx,
int sy)
creates distances from a starting point |
java.util.LinkedList<java.awt.Point> |
getPath(int fromX,
int fromY)
this method returns a path to the fill position. if no path exists, null is returned. if the distance is already zero, an empty list is returned. otherwise, the next cells are returned. if no path exists, null is returned. |
protected char |
i2c(int i)
helper method, converts an integer to a character between 0..9, a..z. wraps around z if input value is to high. |
protected void |
preFill()
initializes the map with initial distances (0 for every cell) |
void |
setAtSwitch(int x,
int y)
marks a cell as adjacent to a switch |
void |
setAttrib(int x,
int y,
byte attr)
sets an attribute for a cell. a cell is a byte value, where 0 indicating an empty cell. |
void |
setObstacle(int x,
int y)
marks a cell as an obstacle (unpassable) |
void |
setPenalty(int x,
int y,
int pen)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int[][] map
int[][] penalty
int[][] attrib
int width
int height
int borderGuard
int fillX
int fillY
static final byte BIT_OBSTACLE
static final byte BIT_ATSWITCH
static int[] relX
static int[] relY
static java.lang.String[] relDir
int[] bestSearches
int[] penSearches
Constructor Detail |
---|
public DistanceMap(int x, int y)
x
- width of mapy
- height of mapMethod Detail |
---|
public void fill(int sx, int sy)
sx
- start xsy
- start yprotected void preFill()
public java.util.LinkedList<java.awt.Point> getPath(int fromX, int fromY)
fromX
- from start xfromY
- from start y
public int distance(int x, int y)
x
- point to query distance for (x)y
- point to query distance for (y)
public void setAttrib(int x, int y, byte attr)
x
- x coordinate party
- y coordinate partattr
- cell attribute to setpublic void setPenalty(int x, int y, int pen)
public void setObstacle(int x, int y)
x
- y
- public void setAtSwitch(int x, int y)
x
- y
- public void debugPrint()
protected char i2c(int i)
i
- positive integer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |