From 5b359edb7a575838ba7ccc33fb5eefd946915b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 Dec 2015 02:40:42 +0100 Subject: PathBuilder: fitness is the count of reached objectives --- core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 10 ++++------ 1 file 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; -- cgit v1.1-2-g2b99