Skip to content

Commit

Permalink
#49: Add proper pathfinding taking VBL into account
Browse files Browse the repository at this point in the history
 - Buildable version...

Task-Url: #49

Signed-off-by: Jamz <[email protected]>
  • Loading branch information
JamzTheMan committed Mar 24, 2018
1 parent f208e9c commit 31a3a11
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ applicationDefaultJvmArgs = ["-Xss4M"]

// Custom properties
ext {
vendor = "Nerps" // Change to RPTools for official builds
vendor = "Nerps-BETA" // Change to RPTools for official builds
git = org.ajoberstar.grgit.Grgit.open(currentDir: file('.'))
revision = git.head().abbreviatedId
revisionFull = git.head().id
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/rptools/maptool/client/MapTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ public static void main(String[] args) {
} else {
DebugStream.deactivate();
}

// List out passed in arguments
for (String arg : args) {
log.info("argument passed via command line: " + arg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

public class ZoneView implements ModelChangeListener {
private static final Logger log = LogManager.getLogger(ZoneView.class);

private final Zone zone;

// VISION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AreaTree {
private static final Logger log = LogManager.getLogger(AreaTree.class);
private AreaOcean theOcean;
private Area theArea; // in case we want to return the original area undigested

public AreaTree(Area area) {
digest(area);
}
Expand All @@ -40,13 +40,14 @@ AreaOcean getOcean() {
public Area getArea() {
return theArea;
}

private void digest(Area area) {
if (area == null) {
return;
}

theArea = area;

List<AreaOcean> oceanList = new ArrayList<AreaOcean>();
List<AreaIsland> islandList = new ArrayList<AreaIsland>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AStarCellPoint(CellPoint p) {
public double cost() {
return h + g;
}

@Override
public int compareTo(AStarCellPoint other) {
return Double.compare(f, other.f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
package net.rptools.maptool.client.walker.astar;

import java.util.List;
import java.util.Set;

import net.rptools.maptool.model.Zone;

public class AStarHorizHexEuclideanWalker extends AbstractAStarHexEuclideanWalker {
Expand Down Expand Up @@ -35,4 +38,10 @@ protected void initNeighborMaps() {
protected int[][] getNeighborMap(int x, int y) {
return y % 2 == 0 ? evenNeighborMap : oddNeighborMap;
}

@Override
protected List<AStarCellPoint> getNeighbors(AStarCellPoint node, Set<AStarCellPoint> closedSet) {
// TODO Auto-generated method stub
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected List<AStarCellPoint> getNeighbors(AStarCellPoint node, Set<AStarCellPo

if (closedSet.contains(neighbor))
continue;

Rectangle cellBounds = zone.getGrid().getBounds(neighbor);

// VBL Check
Expand Down Expand Up @@ -135,7 +135,7 @@ private double metricDistance(CellPoint node, CellPoint goal) {
distance = Math.max(Math.abs(xDist), Math.abs(yDist));
break;
}

return distance;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
package net.rptools.maptool.client.walker.astar;

import java.util.List;
import java.util.Set;

import net.rptools.maptool.model.Zone;

public class AStarVertHexEuclideanWalker extends AbstractAStarHexEuclideanWalker {
Expand All @@ -34,4 +37,10 @@ protected int[][] getNeighborMap(int x, int y) {
return x % 2 == 0 ? evenNeighborMap : oddNeighborMap;
}

@Override
protected List<AStarCellPoint> getNeighbors(AStarCellPoint node, Set<AStarCellPoint> closedSet) {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ protected List<CellPoint> calculatePath(CellPoint start, CellPoint end) {

// If debug is enabled, MapTool is pretty busy so...
double estimatedTimeoutNeeded = 50;
if(log.isDebugEnabled()) {
if (log.isDebugEnabled()) {
estimatedTimeoutNeeded = hScore(start, end) * 10;
log.debug("A* Path timeout estimate: " + estimatedTimeoutNeeded);
}

while (!openList.isEmpty()) {
if (System.currentTimeMillis() > timeOut + estimatedTimeoutNeeded) {
log.info("Timing out...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ protected List<CellPoint> calculatePath(CellPoint start, CellPoint end) {
Area vbl = zone.getTopology();

// If end point is in VBL GTFO
//if (vbl.intersects(zone.getGrid().getBounds(end)))
//return null;
// if (vbl.intersects(zone.getGrid().getBounds(end)))
// return null;

long timeOut = System.currentTimeMillis() + 2000;
// log.info("openList size: " + openList.size());
Expand Down Expand Up @@ -124,7 +124,7 @@ protected List<CellPoint> calculatePath(CellPoint start, CellPoint end) {

Rectangle cellBounds = zone.getGrid().getBounds(neighborNode);
double perc = 0;

if (vbl.intersects(cellBounds)) {
Area cellArea = new Area(cellBounds);
cellArea.intersect(vbl);
Expand Down

0 comments on commit 31a3a11

Please sign in to comment.