Optimizations, small bits of cleanup

main
Bryson Zimmerman 12 months ago
parent 1444be1ee4
commit 14e9b99189

@ -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" default="true" project-jdk-name="temurin-11" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" 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>

@ -5,22 +5,13 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="741ceb24-e493-47c1-9f25-1dbd8b151381" name="Changes" comment="Implemented MazeFinder, significant changes to supporting data structures to match developed understanding of Kotlin and Object-Oriented philosophy"> <list default="true" id="741ceb24-e493-47c1-9f25-1dbd8b151381" name="Changes" comment="Implemented MazeFinder, significant changes to supporting data structures to match developed understanding of Kotlin and Object-Oriented philosophy">
<change afterPath="$PROJECT_DIR$/src/main/kotlin/util/TrimmableArrayList.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/test/kotlin/MazeFinderTest.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/test/kotlin/TileTest.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/test/kotlin/TrimmableArrayListTest.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle.kts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/settings.gradle.kts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/Main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/Main.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/kotlin/Main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/Main.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/Mazefinder.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/Mazefinder.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/kotlin/Mazefinder.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/MazeFinder.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/World.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/World.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/data/Directions.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/Directions.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/kotlin/data/Directions.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/Directions.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/data/Tile.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/Tile.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/kotlin/data/Tile.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/Tile.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/data/TileProperties.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/TileProperties.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/kotlin/data/TileProperties.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/TileProperties.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/data/WorldData.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/data/WorldData.kt" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -122,7 +113,7 @@
<setting file="file://$PROJECT_DIR$/src/main/kotlin/util/TrimmableArrayList.kt" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/src/main/kotlin/util/TrimmableArrayList.kt" root0="FORCE_HIGHLIGHTING" />
</component> </component>
<component name="ProblemsViewState"> <component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" /> <option name="selectedTabId" value="ProjectErrors" />
</component> </component>
<component name="ProjectColorInfo">{ <component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 2 &quot;associatedIndex&quot;: 2
@ -168,6 +159,7 @@
"git-widget-placeholder": "main", "git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "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.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
@ -361,8 +353,8 @@
<component name="SharedIndexes"> <component name="SharedIndexes">
<attachedChunks> <attachedChunks>
<set> <set>
<option value="bundled-jdk-9823dce3aa75-28b599e66164-intellij.indexing.shared.core-IU-242.23339.11" /> <option value="bundled-jdk-9823dce3aa75-28b599e66164-intellij.indexing.shared.core-IU-242.23726.103" />
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-IU-242.23339.11" /> <option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-IU-242.23726.103" />
</set> </set>
</attachedChunks> </attachedChunks>
</component> </component>
@ -379,6 +371,7 @@
<workItem from="1729647683265" duration="4068000" /> <workItem from="1729647683265" duration="4068000" />
<workItem from="1729689482885" duration="6548000" /> <workItem from="1729689482885" duration="6548000" />
<workItem from="1729708627987" duration="3017000" /> <workItem from="1729708627987" duration="3017000" />
<workItem from="1729712667391" duration="3180000" />
</task> </task>
<task id="LOCAL-00001" summary="Project Setup"> <task id="LOCAL-00001" summary="Project Setup">
<option name="closed" value="true" /> <option name="closed" value="true" />

@ -14,8 +14,10 @@ class HierarchicalPathfinding {
companion object { companion object {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
val n = 1000 val n = 5000
println("Building world")
World.setSize(n, n) World.setSize(n, n)
println("Start")
val startTime = System.currentTimeMillis() val startTime = System.currentTimeMillis()
MazeFinder.primsAlgorithm() MazeFinder.primsAlgorithm()
val endTime = System.currentTimeMillis() val endTime = System.currentTimeMillis()

@ -6,8 +6,6 @@ import technology.zim.data.Tile
import technology.zim.data.TileProperties import technology.zim.data.TileProperties
import technology.zim.util.TrimmableArrayList import technology.zim.util.TrimmableArrayList
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlin.collections.forEach
import kotlin.random.Random
//Build the maze //Build the maze

@ -25,10 +25,6 @@ enum class Directions(val value: Pair<Int, Int>) {
//Return the opposite direction //Return the opposite direction
abstract fun opposite(): Directions abstract fun opposite(): Directions
fun all(): MutableSet<Directions> {
return mutableSetOf(NORTH, SOUTH, EAST, WEST)
}
fun x():Int { fun x():Int {
return value.first return value.first
} }
@ -37,4 +33,8 @@ enum class Directions(val value: Pair<Int, Int>) {
return value.second return value.second
} }
companion object {
val ALL = setOf(NORTH, EAST, WEST, SOUTH)
}
} }

@ -1,6 +1,5 @@
package technology.zim.data package technology.zim.data
import technology.zim.MazeFinder
import technology.zim.World import technology.zim.World
class Tile(val value: Pair<Int, Int>): Comparable<Tile> { class Tile(val value: Pair<Int, Int>): Comparable<Tile> {
@ -31,18 +30,26 @@ class Tile(val value: Pair<Int, Int>): Comparable<Tile> {
} }
} }
//Duplicating code from getAdjacent shaved off 100ms
//I'm keeping it
fun getAdjacentTiles(explored:Boolean): Set<Tile> { fun getAdjacentTiles(explored:Boolean): Set<Tile> {
val result = mutableSetOf<Tile>() val adj = mutableSetOf<Tile>()
getAdjacent(explored).forEach { val dirs = Directions.ALL
pair ->
result.add(pair.first) 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<Pair<Tile, Directions>> { fun getAdjacent(explored:Boolean): Set<Pair<Tile, Directions>> {
val adj = mutableSetOf<Pair<Tile, Directions>>() val adj = mutableSetOf<Pair<Tile, Directions>>()
val dirs = Directions.NORTH.all() val dirs = Directions.ALL
dirs.forEach { dir -> dirs.forEach { dir ->
val candidateTile = this + dir val candidateTile = this + dir

@ -1,8 +1,5 @@
package technology.zim.data package technology.zim.data
import technology.zim.World
import technology.zim.World.tiles
//Data holder for a Tile //Data holder for a Tile
//Should contain a mutable set of connected directions //Should contain a mutable set of connected directions
//Later, can hold jumps to other locations other such fancy features //Later, can hold jumps to other locations other such fancy features

Loading…
Cancel
Save