cz.cuni.pogamut.Client
Class GameMapAStarGoal

java.lang.Object
  extended by cz.cuni.pogamut.Client.GameMapAStarGoal
All Implemented Interfaces:
AStarGoal

public class GameMapAStarGoal
extends java.lang.Object
implements AStarGoal


Field Summary
private  NavPoint goalNode
           
 
Constructor Summary
GameMapAStarGoal(NavPoint goalNode)
           
 
Method Summary
 int getEstimatedDistanceToGoal(java.lang.Object node)
          This is heuristic function. !
 int getExtraCost(java.lang.Object nodeFrom, java.lang.Object nodeTo)
          Returns extra cost to add to value when trying to go nodeFrom to nodeTo ... of course it can depends only on nodeTo (some special kind of a floor for instance) Don't worry about the edge cost to become negative, A* ensures that that the least cost is 0 (Algorithm can't work over graphs with negative costs.)
private  NavPoint getNavPoint(java.lang.Object node)
           
 boolean isGoalReached(java.lang.Object actualNode)
          Returns true, if we've reached the goal ... e.g. actualNode is node we were trying to get to if this function never returns true, A* will run until all nodes are evaluated
 boolean isNodeOpened(java.lang.Object node)
          list of flags: R_WALK = 1, //walking required R_FLY = 2, //flying required R_SWIM = 4, //swimming required R_JUMP = 8, // jumping required R_DOOR = 16, // doors R_SPECIAL = 32,// movers R_LADDER = 64, // no idea R_PROSCRIBED = 128, // no idea R_FORCED = 256, // no idea R_PLAYERONLY = 512 // no idea
 void setCloseList(java.util.Collection closeList)
          This is called at the beggining of the A* algorithm to bind the close list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance).
 void setOpenList(java.util.Collection openList)
          This is called at the beggining of the A* algorithm to bind the open list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

goalNode

private NavPoint goalNode
Constructor Detail

GameMapAStarGoal

public GameMapAStarGoal(NavPoint goalNode)
Method Detail

getNavPoint

private NavPoint getNavPoint(java.lang.Object node)

getEstimatedDistanceToGoal

public int getEstimatedDistanceToGoal(java.lang.Object node)
Description copied from interface: AStarGoal
This is heuristic function. !NOTE! That this heuristic must be correct for A* to work correctly, that means the returned distance must be smaller or equal to the real distance. (In 2D, 3D a euklidian metric will do the job).

Specified by:
getEstimatedDistanceToGoal in interface AStarGoal
Returns:
how far is to the goal from the node

getExtraCost

public int getExtraCost(java.lang.Object nodeFrom,
                        java.lang.Object nodeTo)
Description copied from interface: AStarGoal
Returns extra cost to add to value when trying to go nodeFrom to nodeTo ... of course it can depends only on nodeTo (some special kind of a floor for instance) Don't worry about the edge cost to become negative, A* ensures that that the least cost is 0 (Algorithm can't work over graphs with negative costs.)

Specified by:
getExtraCost in interface AStarGoal
Returns:
extra cost of edge for nodeFrom -> nodeTo

isGoalReached

public boolean isGoalReached(java.lang.Object actualNode)
Description copied from interface: AStarGoal
Returns true, if we've reached the goal ... e.g. actualNode is node we were trying to get to if this function never returns true, A* will run until all nodes are evaluated

Specified by:
isGoalReached in interface AStarGoal

isNodeOpened

public boolean isNodeOpened(java.lang.Object node)
list of flags: R_WALK = 1, //walking required R_FLY = 2, //flying required R_SWIM = 4, //swimming required R_JUMP = 8, // jumping required R_DOOR = 16, // doors R_SPECIAL = 32,// movers R_LADDER = 64, // no idea R_PROSCRIBED = 128, // no idea R_FORCED = 256, // no idea R_PLAYERONLY = 512 // no idea

Specified by:
isNodeOpened in interface AStarGoal

setCloseList

public void setCloseList(java.util.Collection closeList)
Description copied from interface: AStarGoal
This is called at the beggining of the A* algorithm to bind the close list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance). DON'T CHANGE IT!

Specified by:
setCloseList in interface AStarGoal

setOpenList

public void setOpenList(java.util.Collection openList)
Description copied from interface: AStarGoal
This is called at the beggining of the A* algorithm to bind the open list to the goal (you may use it check which nodes we've visited, etc... for extra cost for instance). DON'T CHANGE IT!

Specified by:
setOpenList in interface AStarGoal