From 7786a0789f7dc8e08a0179ff78d4f8066bc98d8d Mon Sep 17 00:00:00 2001 From: Bryson Zimmerman Date: Thu, 7 Nov 2024 23:32:39 -0500 Subject: [PATCH] More refactoring --- src/main/kotlin/Main.kt | 2 +- src/main/kotlin/MazeFinder.kt | 4 ++-- src/main/kotlin/PathFinder.kt | 2 +- src/main/kotlin/World.kt | 4 ++-- src/main/kotlin/data/Directions.kt | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 582ac23..9dd4b5c 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -7,7 +7,7 @@ class HierarchicalPathfinding { companion object { @JvmStatic fun main(args: Array) { - val n = 50 + val n = 500 buildMaze(n) val startTime = System.currentTimeMillis() PathFinder.generatePath(Tile(0, 0), Tile(n-1, (n-1))) diff --git a/src/main/kotlin/MazeFinder.kt b/src/main/kotlin/MazeFinder.kt index c0eea5d..1f1060a 100644 --- a/src/main/kotlin/MazeFinder.kt +++ b/src/main/kotlin/MazeFinder.kt @@ -56,7 +56,7 @@ object MazeFinder { current.connect(inGraph) //Look around the frontier tile for unexplored tiles, add them to the frontier - manifestDestiny(current) + addToManifest(current) //print(World.toString()) //println("--------------------------------------------") @@ -65,7 +65,7 @@ object MazeFinder { println("prim") } - private fun manifestDestiny(current: Tile) { + private fun addToManifest(current: Tile) { current.getAdjacentTiles(false).forEach { tile -> val tileprops = World.get(tile) diff --git a/src/main/kotlin/PathFinder.kt b/src/main/kotlin/PathFinder.kt index 371ad07..c0f2b6f 100644 --- a/src/main/kotlin/PathFinder.kt +++ b/src/main/kotlin/PathFinder.kt @@ -54,7 +54,7 @@ object PathFinder { //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.FRONTIERIFIED) + World.update(candidateTile, candidateTile.getProperties() +Directions.FRONTIER) } } } diff --git a/src/main/kotlin/World.kt b/src/main/kotlin/World.kt index f1f5f2e..ac227c1 100644 --- a/src/main/kotlin/World.kt +++ b/src/main/kotlin/World.kt @@ -64,7 +64,7 @@ object World { for (x in 0..tiles.value[0].size - 1) { if(World.get(Tile(x, y)).connections and(INPATH.dir) != 0) inPath = true - else if (World.get(Tile(x, y)).connections and(FRONTIERIFIED.dir) != 0) + else if (World.get(Tile(x, y)).connections and(FRONTIER.dir) != 0) checked = true if(inPath) str.append(ANSI_GREEN) @@ -103,7 +103,7 @@ object World { } } fun getTileShapeDoubles(tile: TileProperties): Char { - return when(tile.connections and(MANIFEST.inv()) and(INPATH.inv()) and(FRONTIERIFIED.inv())) { + return when(tile.connections and(MANIFEST.inv()) and(INPATH.inv()) and(FRONTIER.inv())) { UP.dir+DOWN.dir+LEFT.dir+RIGHT.dir -> '╬' UP.dir+DOWN.dir+LEFT.dir -> '╣' UP.dir+DOWN.dir+RIGHT.dir -> '╠' diff --git a/src/main/kotlin/data/Directions.kt b/src/main/kotlin/data/Directions.kt index 99f9e1b..9c20db7 100644 --- a/src/main/kotlin/data/Directions.kt +++ b/src/main/kotlin/data/Directions.kt @@ -6,8 +6,8 @@ enum class Directions(val dir: Int) { DOWN(2), LEFT(4), RIGHT(8), - MANIFEST(16),//Checked by MazeFinder, the imperialist way - FRONTIERIFIED(32), //Added to the pathfinder's frontier + 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 ;