Some initial PathFinder work

main
Bryson Zimmerman 11 months ago
parent 9ee0a07c9c
commit f709e4dc01

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration"> <component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" /> <file type="web" url="file://$PROJECT_DIR$" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="temurin-11" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="temurin-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

@ -0,0 +1,40 @@
package technology.zim
import technology.zim.data.Tile
import kotlin.math.abs
//A* to be upgraded with hierarchies
//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 PathFinder {
val path = ArrayDeque<Tile>()
//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")
}
}
//Heuristic value, to estimate the cost of a given tile
fun hValue(prospect: Tile, end: Tile): Int {
return abs(prospect.x() - end.x()) + abs(prospect.y() - end.y())
}
//Step through the path, marking each Tile with INPATH
fun finalizePath() {
}
}

@ -1,10 +0,0 @@
package technology.zim
//A* to be upgraded with hierarchies
//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
class Pathfinder {
}
Loading…
Cancel
Save