diff --git a/src/test/kotlin/MazeFinderTest.kt b/src/test/kotlin/MazeFinderTest.kt index 910fe73..3d41606 100644 --- a/src/test/kotlin/MazeFinderTest.kt +++ b/src/test/kotlin/MazeFinderTest.kt @@ -13,46 +13,41 @@ class MazeFinderTest { MazeFinder.primsAlgorithm() } + //Top row must have at least one south connection and no north connections @Test fun topRowOutOfBoundsCheck() { var southExists = false - World.tiles.value.forEach { - col -> - if(col[0].isSouth()) + for(x in 0.. - if(col[9].isSouth()) - southNotExists = false + for(x in 0.. - col.forEach { - tile -> - assert(tile.visited()) + for(x in 0.. - col.forEachIndexed { y, - tileprop -> + for(x in 0..() - var heap = TileHeap(Tile(20, 20), gVals) + var heap = TileHeap(Tile(20, 20), this::fValue) + private fun fValue(prospect: Tile, end: Tile): Int { + return hValue(prospect, end).plus(gVals.get(prospect) ?: 0) + } + + private fun hValue(prospect: Tile, end:Tile): Int { + return abs(prospect.x() - end.x()) + abs(prospect.y() - end.y()) + } } @BeforeTest fun setUp() { - heap = TileHeap(Tile(20, 20), gVals) + heap = TileHeap(Tile(20, 20), Companion::fValue) arrayOf(Tile(0, 0), Tile(1, 1), Tile(5, 5), Tile(4, 4), Tile(19, 19), Tile(2, 2)).forEach { item -> heap.insert(item) }