diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 20:51:24 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 20:51:24 +0100 |
commit | 480b3f753cc68799db7ec0d440d8c995730e23c1 (patch) | |
tree | 0dbee8c21092b28831f9472017ce606ea42d39e3 /core/src | |
parent | 1b4531faaf6737cc1eb5626a88f29272d6dc7bc5 (diff) | |
download | RustAndDust-480b3f753cc68799db7ec0d440d8c995730e23c1.zip RustAndDust-480b3f753cc68799db7ec0d440d8c995730e23c1.tar.gz |
PathBuilder: add chooseShortest()
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index 2846928..ca25535 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -140,6 +140,25 @@ public class PathBuilder implements Disposable return 1; } + public int chooseShortest() + { + if (paths.size() > 1) { + Path good = paths.get(0); + for (Path path : paths) { + if (path.tiles.size() < good.tiles.size()) + good = path; + } + + paths.remove(good); + clearPaths(); + paths.add(good); + for (Tile tile : good.tiles) + tiles.add(tile); + } + + return 1; + } + private void findAllPaths(Tile from, int mvtLeft, int fitness, boolean roadMarch) { Tile moves[] = new Tile[6]; |