From 007779ce3693aa6fc49968568de30fd9b9bea688 Mon Sep 17 00:00:00 2001 From: Bryson Zimmerman Date: Thu, 14 Nov 2024 21:42:17 -0500 Subject: [PATCH] Added distinct path tracking for each algorithm --- src/main/kotlin/MapBackedPathfinder.kt | 4 ++-- src/main/kotlin/data/Directions.kt | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/MapBackedPathfinder.kt b/src/main/kotlin/MapBackedPathfinder.kt index 9d27c5a..2124f45 100644 --- a/src/main/kotlin/MapBackedPathfinder.kt +++ b/src/main/kotlin/MapBackedPathfinder.kt @@ -46,7 +46,7 @@ object MapBackedPathfinder { //Otherwise, the tile has been reached and this path is not better, so carry on gVals.put(candidateTile, currentG + 1) frontier.insert(candidateTile) - World.update(candidateTile, candidateTile.getProperties() +Directions.FRONTIER) + World.update(candidateTile, candidateTile.getProperties() +Directions.HMFRONTIER) } } } while( current != end) @@ -70,7 +70,7 @@ object MapBackedPathfinder { var lowestG = Int.MAX_VALUE var lowestCost = end while(current != start) { - World.update(current, current.getProperties() + Directions.INPATH) + World.update(current, current.getProperties() + Directions.HMINPATH) current.getConnections().forEach { candidateTile -> val candidateG = gVals.get(candidateTile) ?: -1 if(candidateTile.isInBounds() && candidateG != -1 && candidateG < lowestG ) { diff --git a/src/main/kotlin/data/Directions.kt b/src/main/kotlin/data/Directions.kt index ae2c07e..a0f62c6 100644 --- a/src/main/kotlin/data/Directions.kt +++ b/src/main/kotlin/data/Directions.kt @@ -7,9 +7,13 @@ enum class Directions(val dir: Int) { LEFT(4), RIGHT(8), MANIFEST(16),//Was added to MazeFinder's frontier, but the pathfinder has a frontier so this is named something other than frontier - FRONTIER(32), //Added to the pathfinder's frontier - INPATH(64), //Chosen by the pathfinder - NOPATH(128) //Tile is not a viable path + FRONTIER(32), //Added to the ArrayBackedPathfinder's frontier + INPATH(64), //Chosen by the ArrayBackedPathfinder + HMFRONTIER(128), //Tile is not a viable path + HMINPATH(256), + BFSFRONTIER(512), + BFSINPATH(1024), + ; companion object {