From b8d524c48af7b38eaec7d2547844c8b76b7009d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 21 Dec 2015 19:32:25 +0100 Subject: PathBuilder: fitness takes objectives into account --- core/src/ch/asynk/rustanddust/engine/Board.java | 1 + core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 1 + core/src/ch/asynk/rustanddust/game/map/Map0Hex.java | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index ba9e1a1..b934030 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -66,6 +66,7 @@ public abstract class Board implements Disposable, Animation protected SelectedTile selectedTile; abstract protected Config getConfig(); + abstract protected boolean isObjective(Tile tile); protected Board(int cols, int rows) { diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index 2f8017c..bc51ab6 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -152,6 +152,7 @@ public class PathBuilder implements Disposable int n = next.costFrom(pawn, o); boolean r = next.road(o); int f = (fitness + 1 + (r ? 0 : 1)); + if (board.isObjective(next)) f -= 2; int m = (mvtLeft - n); r &= roadMarch; diff --git a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java index c1ab73a..0d28829 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java @@ -76,6 +76,12 @@ public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb public void hexExitHide(Hex hex) { enableOverlayOn(hex, Hex.EXIT, false); } @Override + public boolean isObjective(Tile tile) + { + return objectives.containsKey(tile); + } + + @Override public void showObjective(Tile tile, Faction faction) { showObjective((Hex) tile, (Army) faction); -- cgit v1.1-2-g2b99