More refactoring

main
Bryson Zimmerman 11 months ago
parent 7fbaea08da
commit 7786a0789f

@ -7,7 +7,7 @@ class HierarchicalPathfinding {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val n = 50
val n = 500
buildMaze(n)
val startTime = System.currentTimeMillis()
PathFinder.generatePath(Tile(0, 0), Tile(n-1, (n-1)))

@ -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)

@ -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)
}
}
}

@ -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 -> '╠'

@ -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
;

Loading…
Cancel
Save