Compare commits

..

No commits in common. '7d1ec41f06f92aac8fb6f7f96d222da96febe8ba' and '983bbdb51bc10577a9eaaad25e193e1f1f9b2956' have entirely different histories.

@ -52,7 +52,7 @@ object BFSPathfinder {
while(current != start) { while(current != start) {
World.update(current, current.getProperties() + Directions.BFSINPATH) World.update(current, current.getProperties() + Directions.BFSINPATH)
current.getConnections().forEach { candidateTile -> current.getConnections().forEach { candidateTile ->
val candidateG = gVals.get(candidateTile) ?: (-1).also { println("Missing gVal at ${candidateTile.toString()}")} val candidateG = gVals.get(candidateTile) ?: -1
if(candidateTile.isInBounds() && candidateG != -1 && candidateG < lowestG ) { if(candidateTile.isInBounds() && candidateG != -1 && candidateG < lowestG ) {
lowestG = candidateG lowestG = candidateG
lowestCost = candidateTile lowestCost = candidateTile

@ -1,20 +1,11 @@
package technology.zim package technology.zim
import technology.zim.data.Tile import technology.zim.data.Tile
import java.text.NumberFormat
import java.util.Locale import java.util.Locale
import kotlin.time.measureTime import kotlin.time.measureTime
class HierarchicalPathfinding { class HierarchicalPathfinding {
/*
Next steps:
Dump results as CSV
Dump ANSI text to file for processing into image
Add command line options to run particular pathfinders, render particular pathfinder's markings
Add HPA*, should be a bit easier with existing abstractions. Hard part will be the path calculations
Use R to render syntax highlights https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/kotlin.xml
https://pandoc.org/MANUAL.html#syntax-highlighting
https://hamel.dev/notes/quarto/highlighting.html
*/
companion object { companion object {
@JvmStatic @JvmStatic
@ -40,14 +31,13 @@ class HierarchicalPathfinding {
MapBackedPathfinder.generatePath(Tile(0, 0), Tile(n - 1, (n - 1))) MapBackedPathfinder.generatePath(Tile(0, 0), Tile(n - 1, (n - 1)))
} }
val numberFormat = NumberFormat.getInstance(Locale.US)
println(World.toString()) println(World.toString())
print("Tiles in Maze: ") println(numberFormat.format(n*n))
println(String.format(Locale.US, "%,d", n*n)) println("Maze build time: ${numberFormat.format(buildMazeTime.inWholeMilliseconds)} ms")
println("Maze build time: ${String.format(Locale.US, "%,d",buildMazeTime.inWholeMilliseconds)} ms") println("BFS Pathfinder time: ${numberFormat.format(bfsPathfinderTime.inWholeMilliseconds)}ms")
println("BFS Pathfinder time: ${String.format(Locale.US, "%,d",bfsPathfinderTime.inWholeMilliseconds)}ms") println("Array-Backed Pathfinder time: ${numberFormat.format(arrayBackedPathfinderTime.inWholeMilliseconds)}ms")
println("Array-Backed A* Pathfinder time: ${String.format(Locale.US, "%,d",arrayBackedPathfinderTime.inWholeMilliseconds)}ms") println("HashMap-Backed Pathfinder time: ${numberFormat.format(mapBackedPathfinderTime.inWholeMilliseconds)}ms")
println("HashMap-Backed A* Pathfinder time: ${String.format(Locale.US, "%,d",mapBackedPathfinderTime.inWholeMilliseconds)}ms")
} }
fun buildMaze(n: Int) { fun buildMaze(n: Int) {

Loading…
Cancel
Save