Tidying of unused imports and defunct comments

main
Bryson Zimmerman 10 months ago
parent f4979a1e20
commit a2e92ca65f

@ -9,14 +9,10 @@ import kotlin.math.abs
//A* pathfinder backed by an array to improve efficiency
//Needs https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PriorityQueue.html
//and https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Comparator.html
object ArrayBackedPathfinder {
var gVals = TileNavigatedArray<Int>(World.sizeX, World.sizeY, false)
var pathLength = 0
//work along the path, marking tiles with VISITED along the way
//if marking with visited is too expensive, just make the path and finalize it
fun generatePath(start: Tile, end: Tile) {
if(!start.isInBounds() || !end.isInBounds()) {
throw IndexOutOfBoundsException("Cannot generate a path to or from an out of bounds tile")
@ -31,7 +27,7 @@ object ArrayBackedPathfinder {
gVals = TileNavigatedArray<Int>(World.sizeX, World.sizeY, false)
val frontier = TileHeap(end, this::fValue)
//Prime the things
//Prime the frontier
gVals.set(start, 0)
frontier.insert(start)
@ -42,7 +38,6 @@ object ArrayBackedPathfinder {
current = frontier.popMin()
currentG = gVals.get(current) ?: 0.also { println("Failed to get gVal that must exist") }
current.getConnections().forEach { candidateTile ->
val candidateG = gVals.get(candidateTile)?:-1
//Ensure that the tile is within bounds
@ -58,7 +53,6 @@ object ArrayBackedPathfinder {
//At this point, a path is found
markPath(start, end)
//println("Path found!")
}
fun markPath(start: Tile, end:Tile) {

@ -23,7 +23,11 @@ object BFSPathfinder {
//Queue for tiles to be checked
val frontier = ArrayDeque<Tile>()
frontier.addLast(start)
//Set the starting Tile's gValue to 0 because it is 0 steps away from itself
gVals.set(start, 0)
//Add the starting tile to the frontier to kick off the process
World.update(start, Directions.BFSFRONTIER)
var current:Tile

@ -136,10 +136,4 @@ object World {
else -> '•'
}
}
//Reads array left to right, top to bottom
//Only looks at SOUTH and EAST connections
//Either connection exists or it does not, whitespace character for exists, some block-appearing char for not
//Needs one monowidth char space between each column of array
//Needs one line between each row, line containing vertical connections
}

@ -18,7 +18,7 @@ enum class Directions(val dir: Int) {
companion object {
//Todo: This breaks the connect() function when used
//Todo: This breaks the connect() function when used. Fixing it would be nice, but is unnecessary.
fun opposite(dir: Directions): Directions {
return when(dir) {
UP -> DOWN

@ -1,8 +1,5 @@
package technology.zim.data
import java.util.Arrays
import kotlin.arrayOfNulls
//Generic array that accepts a Tile for item lookups
//Row-major for improved memory locality.. maybe make it flexible?

Loading…
Cancel
Save