diff --git a/src/main/kotlin/MazeFinder.kt b/src/main/kotlin/MazeFinder.kt index 9aefb90..637717b 100644 --- a/src/main/kotlin/MazeFinder.kt +++ b/src/main/kotlin/MazeFinder.kt @@ -23,7 +23,7 @@ object MazeFinder { var startingTile = World.getRandomLocation() val randGen = XoRoShiRo128PlusRandom() - val tempInGraph = ArrayList>() + val tempInGraph = ArrayList() fun primsAlgorithm() { cleanUp() @@ -36,6 +36,8 @@ object MazeFinder { startingTile = World.getRandomLocation() val tmpIndex = randGen.nextInt(Directions.ALL.size) startingTile.connect(Directions.ALL.get(tmpIndex)) + tempInGraph.add(startingTile) + tempInGraph.add(startingTile + Directions.ALL.get(tmpIndex)) //Choose an arbitrary vertex from G (the graph), and add it to some (initially empty) set V. frontier.addAll(startingTile.getAdjacentTiles(false)) frontier.addAll((startingTile + Directions.ALL.get(tmpIndex)).getAdjacentTiles(false)) @@ -47,7 +49,6 @@ object MazeFinder { //Grab a random tile from the frontier, mark it as visited val random = randGen.nextInt(frontier.size()) current = frontier.data.get(random) - current.getProperties().visited() frontier.removeAt(random) @@ -55,13 +56,18 @@ object MazeFinder { adjacentExplored = current.getAdjacentTiles(true) if(adjacentExplored.isEmpty()) - println("No explored adjacent tiles found") + println("") + if(adjacentExplored.isEmpty()) { + val world = World.tiles + println ("No explored adjacent tiles found") + } //Select a random tile from possibleTiles inGraph = adjacentExplored.elementAt(randGen.nextInt(adjacentExplored.size)) //Connect the frontier tile to the graph - current.connect(Directions.convertModifier(current.value - inGraph.value)) + current.connect(inGraph) + tempInGraph.add(current) //Add current's unexplored tiles to the frontier, if not already in frontier frontier.addAll(current.getAdjacentTiles(false)) @@ -73,7 +79,6 @@ object MazeFinder { println("prim") } - fun cleanUp() { //Clean up the frontier frontier.clear() diff --git a/src/test/kotlin/MazeFinderTest.kt b/src/test/kotlin/MazeFinderTest.kt index ef782f5..cd414ce 100644 --- a/src/test/kotlin/MazeFinderTest.kt +++ b/src/test/kotlin/MazeFinderTest.kt @@ -15,7 +15,7 @@ class MazeFinderTest { } @Test - fun topRowConnectedSouth() { + fun topRowOutOfBoundsCheck() { var southExists = false World.tiles.value.forEach { col -> @@ -26,7 +26,7 @@ class MazeFinderTest { } @Test - fun bottomRowConnectedSouth() { + fun bottomRowOutOfBoundsCheck() { var southNotExists = true World.tiles.value.forEach { col ->