summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-31 02:40:42 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-31 02:40:42 +0100
commit5b359edb7a575838ba7ccc33fb5eefd946915b0d (patch)
treebdcc628df610668ad392b249064e1565ba1f217e /core/src/ch/asynk
parent97e8ffc7115d100e29e50f3a80bc933eba89bd78 (diff)
downloadRustAndDust-5b359edb7a575838ba7ccc33fb5eefd946915b0d.zip
RustAndDust-5b359edb7a575838ba7ccc33fb5eefd946915b0d.tar.gz
PathBuilder: fitness is the count of reached objectives
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java10
1 files changed, 4 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index e941632..c458369 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -117,12 +117,11 @@ public class PathBuilder implements Disposable
public int choosePath()
{
if (paths.size() > 1) {
- int f = Integer.MAX_VALUE;
- Path good = null;
+ Path good = paths.get(0);
for (Path path : paths) {
- if (path.fitness < f) {
+ if ( (path.fitness > good.fitness) || ((path.fitness == good.fitness) && (path.cost < good.cost))) {
+ good = path;
good = path;
- f = path.fitness;
}
}
@@ -148,8 +147,7 @@ public class PathBuilder implements Disposable
Orientation o = board.getSide(i);
int n = next.costFrom(pawn, o);
boolean r = next.road(o);
- int f = (fitness + 1 + (r ? 0 : 1));
- if (next.isObjectiveFor(pawn)) f -= 4;
+ int f = (fitness + (next.isObjectiveFor(pawn) ? 1 : 0));
int m = (mvtLeft - n);
r &= roadMarch;