コード例 #1
0
 def test_swapping_adds_to_tile_history(self):
     tile = Tile()
     tile.history = [[[1, 2, 3], [8, 0, 4], [7, 6, 5]]]
     tile.layout = [[1, 2, 3], [8, 4, 0], [7, 6, 5]]
     expected = [[[1, 2, 3], [8, 0, 4], [7, 6, 5]],
                 [[1, 2, 3], [8, 4, 0], [7, 6, 5]]]
     self.assertEqual(
         Tile.swap(Tile.duplicate(tile), 0, 2, 1, 2).history, expected)
コード例 #2
0
 def test_displaced_tiles_yields_two(self):
     tile = Mover.move_left(Tile.duplicate(self.tile))
     tile = Mover.move_up(tile)
     self.assertEqual(self.metrics.displaced(tile), 2)
コード例 #3
0
ファイル: mover.py プロジェクト: staujd02/tile-puzzle-solver
 def move_horizontally(tile, direction, rowIndex, squareIndex):
     if (squareIndex == direction + 1):
         return None
     return Tile.swap(Tile.duplicate(tile), rowIndex,
                      squareIndex + direction, rowIndex, squareIndex)