diff --git a/.idea/misc.xml b/.idea/misc.xml
index ee3319a..40daec2 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7264ad1..98a458a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,22 +5,13 @@
-
-
-
-
-
-
-
-
-
+
-
@@ -122,7 +113,7 @@
-
+
{
"associatedIndex": 2
@@ -168,6 +159,7 @@
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/Bryson/Documents/GitHub/HierarchicalPathfinding",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@@ -361,8 +353,8 @@
-
-
+
+
@@ -379,6 +371,7 @@
+
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index ef40c48..1aa8f33 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -14,8 +14,10 @@ class HierarchicalPathfinding {
companion object {
@JvmStatic
fun main(args: Array) {
- val n = 1000
+ val n = 5000
+ println("Building world")
World.setSize(n, n)
+ println("Start")
val startTime = System.currentTimeMillis()
MazeFinder.primsAlgorithm()
val endTime = System.currentTimeMillis()
diff --git a/src/main/kotlin/Mazefinder.kt b/src/main/kotlin/MazeFinder.kt
similarity index 97%
rename from src/main/kotlin/Mazefinder.kt
rename to src/main/kotlin/MazeFinder.kt
index 1f56f3e..2459f69 100644
--- a/src/main/kotlin/Mazefinder.kt
+++ b/src/main/kotlin/MazeFinder.kt
@@ -6,8 +6,6 @@ import technology.zim.data.Tile
import technology.zim.data.TileProperties
import technology.zim.util.TrimmableArrayList
import kotlin.collections.ArrayList
-import kotlin.collections.forEach
-import kotlin.random.Random
//Build the maze
diff --git a/src/main/kotlin/data/Directions.kt b/src/main/kotlin/data/Directions.kt
index e7b8db4..fc02f80 100644
--- a/src/main/kotlin/data/Directions.kt
+++ b/src/main/kotlin/data/Directions.kt
@@ -25,10 +25,6 @@ enum class Directions(val value: Pair) {
//Return the opposite direction
abstract fun opposite(): Directions
- fun all(): MutableSet {
- return mutableSetOf(NORTH, SOUTH, EAST, WEST)
- }
-
fun x():Int {
return value.first
}
@@ -37,4 +33,8 @@ enum class Directions(val value: Pair) {
return value.second
}
+ companion object {
+ val ALL = setOf(NORTH, EAST, WEST, SOUTH)
+ }
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/data/Tile.kt b/src/main/kotlin/data/Tile.kt
index 717bc81..ad6e5a7 100644
--- a/src/main/kotlin/data/Tile.kt
+++ b/src/main/kotlin/data/Tile.kt
@@ -1,6 +1,5 @@
package technology.zim.data
-import technology.zim.MazeFinder
import technology.zim.World
class Tile(val value: Pair): Comparable {
@@ -31,18 +30,26 @@ class Tile(val value: Pair): Comparable {
}
}
+ //Duplicating code from getAdjacent shaved off 100ms
+ //I'm keeping it
fun getAdjacentTiles(explored:Boolean): Set {
- val result = mutableSetOf()
- getAdjacent(explored).forEach {
- pair ->
- result.add(pair.first)
+ val adj = mutableSetOf()
+ val dirs = Directions.ALL
+
+ dirs.forEach { dir ->
+ val candidateTile = this + dir
+ //Ensure that the tile is within bounds
+ if(candidateTile.isInBounds() && candidateTile.getProperties().visited == explored)
+ {
+ adj.add(candidateTile)
+ }
}
- return result
+ return adj
}
fun getAdjacent(explored:Boolean): Set> {
val adj = mutableSetOf>()
- val dirs = Directions.NORTH.all()
+ val dirs = Directions.ALL
dirs.forEach { dir ->
val candidateTile = this + dir
diff --git a/src/main/kotlin/data/TileProperties.kt b/src/main/kotlin/data/TileProperties.kt
index eef983d..6b3c56a 100644
--- a/src/main/kotlin/data/TileProperties.kt
+++ b/src/main/kotlin/data/TileProperties.kt
@@ -1,8 +1,5 @@
package technology.zim.data
-import technology.zim.World
-import technology.zim.World.tiles
-
//Data holder for a Tile
//Should contain a mutable set of connected directions
//Later, can hold jumps to other locations other such fancy features