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)
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)
def move_horizontally(tile, direction, rowIndex, squareIndex): if (squareIndex == direction + 1): return None return Tile.swap(Tile.duplicate(tile), rowIndex, squareIndex + direction, rowIndex, squareIndex)