summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-05 10:19:29 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-05 10:19:29 +0100
commitc1b741955570b98003e81ba054cb6c217b9c3d0b (patch)
tree0c4ef2da781177acde8482cfb489de3064474eab /core/src/ch/asynk/tankontank
parent20c0304cb2cfd8b9f1add8d5481a2beb72a5caea (diff)
downloadRustAndDust-c1b741955570b98003e81ba054cb6c217b9c3d0b.zip
RustAndDust-c1b741955570b98003e81ba054cb6c217b9c3d0b.tar.gz
Tile,Hex: int costFrom(Pawn, Orientation, boolean) -> int costFrom(Pawn, Orientation)
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/engine/PossiblePaths.java13
-rw-r--r--core/src/ch/asynk/tankontank/engine/SearchBoard.java7
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java4
4 files changed, 12 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
index 417856e..55a5cd9 100644
--- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
+++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
@@ -104,10 +104,10 @@ public class PossiblePaths implements Iterable<Vector3>
Tile next = moves[i];
if (next == null) continue;
- boolean road = next.road(board.getSide(i));
- int cost = next.costFrom(pawn, board.getSide(i), road);
+ int cost = next.costFrom(pawn, board.getSide(i));
int r = (mvtLeft - cost);
- if (roadMarch & road) r += pawn.getRoadMarchBonus();
+ roadMarch &= next.road(board.getSide(i));
+ if (roadMarch) r += pawn.getRoadMarchBonus();
if ((board.distance(next, to) <= r)) {
if (next == to) {
@@ -119,7 +119,7 @@ public class PossiblePaths implements Iterable<Vector3>
for (Tile tile : temp) tiles.add(tile);
} else {
stack.add(next);
- findAllPaths(next, (mvtLeft - cost), (roadMarch & road));
+ findAllPaths(next, (mvtLeft - cost), roadMarch);
stack.remove(stack.size() - 1);
}
}
@@ -174,9 +174,8 @@ public class PossiblePaths implements Iterable<Vector3>
for (Tile next : paths.get(i)) {
if (prev != null) {
Orientation o = Orientation.fromMove(next.col, next.row, prev.col, prev.row);
- boolean road = next.road(o);
- cost += next.costFrom(pawn, o, road);
- roadMarch &= road;
+ cost += next.costFrom(pawn, o);
+ roadMarch &= next.road(o);
}
prev = next;
}
diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
index 840650c..2c5e326 100644
--- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java
+++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
@@ -149,11 +149,10 @@ public class SearchBoard
if (dst != null) {
Tile t = getTile(dst);
- boolean road = t.road(board.getSide(i));
- int cost = t.costFrom(pawn, board.getSide(i), road);
+ int cost = t.costFrom(pawn, board.getSide(i));
boolean mayMoveOne = first && t.atLeastOneMove(pawn);
int r = src.remaining - cost;
- boolean roadMarch = road && src.roadMarch;
+ boolean roadMarch = (src.roadMarch && t.road(board.getSide(i)));
if (dst.search == searchCount) {
if ((r >= 0) && ((r > dst.remaining) || (roadMarch && ((r + roadMarchBonus) >= dst.remaining)))) {
@@ -194,7 +193,7 @@ public class SearchBoard
Tile t = getTile(dst);
if (!t.road(board.getSide(i)))
continue;
- int cost = t.costFrom(pawn, board.getSide(i), true);
+ int cost = t.costFrom(pawn, board.getSide(i));
int r = src.remaining - cost;
if (dst.search == searchCount) {
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java
index 539725b..4065346 100644
--- a/core/src/ch/asynk/tankontank/engine/Tile.java
+++ b/core/src/ch/asynk/tankontank/engine/Tile.java
@@ -25,7 +25,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn>
private ArrayDeque<Pawn> stack;
public abstract int defenseFor(Pawn pawn, Pawn target, Board.PawnCollection foes);
- public abstract int costFrom(Pawn pawn, Orientation side, boolean road);
+ public abstract int costFrom(Pawn pawn, Orientation side);
public abstract boolean isOffMap();
public abstract boolean road(Orientation side);
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 7c23392..302dc86 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -84,10 +84,10 @@ public class Hex extends Tile
}
@Override
- public int costFrom(Pawn pawn, Orientation side, boolean road)
+ public int costFrom(Pawn pawn, Orientation side)
{
if (hasUnits()) return Integer.MAX_VALUE;
- if (road) return 1;
+ if (road(side)) return 1;
int c = 0;
switch(terrain) {