summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-12 22:31:19 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-12 22:31:19 +0100
commit60e6f04e48b1b232632dfd579247e8a15c9635f6 (patch)
tree10fb9c8632889b16a87e91532f30d8e651950f3f /core/src/ch/asynk/tankontank/engine
parentcc96310a9a8bb040f3af7f8f4f5a1c9225dd6933 (diff)
downloadRustAndDust-60e6f04e48b1b232632dfd579247e8a15c9635f6.zip
RustAndDust-60e6f04e48b1b232632dfd579247e8a15c9635f6.tar.gz
Board,Map...: fix findEntryPoint(...)
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java43
1 files changed, 16 insertions, 27 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index e765ab0..1b621c0 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -344,38 +344,27 @@ public abstract class Board implements Disposable
return assists.size();
}
- public Orientation findBestEntry(Pawn pawn, Tile to, Orientation from)
+ public Orientation findBestEntry(Pawn pawn, Tile to, int allowedMoves)
{
- // FIXME board corners
Orientation entry = Orientation.KEEP;
int cost = Integer.MAX_VALUE;
boolean road = false;
- Orientation o = from.opposite().left();
- boolean r = to.road(o);
- int c = to.costFrom(pawn, o);
- if ((c < cost) || (r && (c == cost))) {
- entry = o;
- cost = c;
- road = r;
- }
-
- o = from.opposite();
- r = to.road(o);
- c = to.costFrom(pawn, o);
- if ((c < cost) || (r && (c == cost))) {
- entry = o;
- cost = c;
- road = r;
- }
-
- o = from.opposite().right();
- r = to.road(o);
- c = to.costFrom(pawn, o);
- if ((c < cost) || (r && (c == cost))) {
- entry = o;
- cost = c;
- road = r;
+ setAdjacentTiles(to, neighbours);
+ for (int i = 0; i < 6; i++) {
+ Tile t = neighbours[i];
+ if (t.isOffMap()) {
+ Orientation o = Orientation.fromAdj(t.col, t.row, to.col, to.row);
+ if (o.isInSides(allowedMoves)) {
+ boolean r = to.road(o);
+ int c = to.costFrom(pawn, o);
+ if ((c < cost) || (r && (c == cost))) {
+ entry = o;
+ cost = c;
+ road = r;
+ }
+ }
+ }
}
return entry;