Can you help me trying to do this code because I am struggling big time with this. question that i need help with: the Eight Puzzle consists of a 3 x 3 board of sliding tiles with a single empty space. For each configuration, the only possible moves are to swap the empty tile with one of its neighboring tiles. The goal state for the puzzle consists of tiles 1-3 in the top row, tiles 4-6 in the middle row, and tiles 7 and 8 in the bottom row, with the empty space in the lower-right corner.you will develop two solvers for a generalized version of the Eight Puzzle, in which the board can have any number of rows and columns. A natural representation for this puzzle is a two-dimensional list of integer values between 0 and r · c -1 (inclusive), where r and c are the number of rows and columns in the board, respectively. In this problem, we will adhere to the convention that the 0-tile represents the empty space. tasks: In the TilePuzzle class, write an initialization method __init__(self, board) that stores an input board of this form described above for future use. You additionally may wish to store the dimensions of the board as separate internal variables, as well as the location of the empty tile. In the TilePuzzle class, write a method get_board(self) that returns the internal representation of the board stored during initialization. >>> p = TilePuzzle([[1, 2], [3, 0]]) >>> p.get_board() [[1, 2], [3, 0]] >>> p = TilePuzzle([[0, 1], [3, 2]]) >>> p.get_board() [[0, 1], [3, 2]] Write a top-level function create_tile_puzzle(rows, cols) that returns a new TilePuzzle of the specified dimensions, initialized to the starting configuration. Tiles 1 through r · c - 1 should be arranged starting from the top-left corner in row-major order, and tile 0 should be located in the lower-right corner. >>> p = create_tile_puzzle(3, 3) >>> p.get_board() [[1, 2, 3], [4, 5, 6], [7, 8, 0]] >>> p = create_tile_puzzle(2, 4) >>> p.get_board() [[1, 2, 3, 4], [5, 6, 7, 0]] this has to be in the code: def create_tile_puzzle(rows, cols): pass class TilePuzzle(object): # Required def __init__(self, board): pass def get_board(self): pass def perform_move(self, direction): pass def scramble(self, num_moves): pass def is_solved(self): pass def copy(self): pass def successors(self): pass # Required def find_solutions_iddfs(self): pass # Required def find_solution_a_star(self): pass
Can you help me trying to do this code because I am struggling big time with this.
question that i need help with:
the Eight Puzzle consists of a 3 x 3 board of sliding tiles with a single empty space. For each configuration, the only possible moves are to swap the empty tile with one of its neighboring tiles. The goal state for the puzzle consists of tiles 1-3 in the top row, tiles 4-6 in the middle row, and tiles 7 and 8 in the bottom row, with the empty space in the lower-right corner.you will develop two solvers for a generalized version of the Eight Puzzle, in which the board can have any number of rows and columns.
A natural representation for this puzzle is a two-dimensional list of integer values between 0 and r · c -1 (inclusive), where r and c are the number of rows and columns in the board, respectively. In this problem, we will adhere to the convention that the 0-tile represents the empty space.
tasks:
In the TilePuzzle class, write an initialization method __init__(self, board) that stores an input board of this form described above for future use. You additionally may wish to store the dimensions of the board as separate internal variables, as well as the location of the empty tile.
In the TilePuzzle class, write a method get_board(self) that returns the internal representation of the board stored during initialization.
>>> p = TilePuzzle([[1, 2], [3, 0]])
>>> p.get_board()
[[1, 2], [3, 0]]
>>> p = TilePuzzle([[0, 1], [3, 2]])
>>> p.get_board()
[[0, 1], [3, 2]]
Write a top-level function create_tile_puzzle(rows, cols) that returns a new TilePuzzle of the specified dimensions, initialized to the starting configuration. Tiles 1 through r · c - 1 should be arranged starting from the top-left corner in row-major order, and tile 0 should be located in the lower-right corner.
>>> p = create_tile_puzzle(3, 3)
>>> p.get_board()
[[1, 2, 3], [4, 5, 6], [7, 8, 0]]
>>> p = create_tile_puzzle(2, 4)
>>> p.get_board()
[[1, 2, 3, 4], [5, 6, 7, 0]]
this has to be in the code:
pass
class TilePuzzle(object):
# Required
def __init__(self, board):
pass
def get_board(self):
pass
def perform_move(self, direction):
pass
def scramble(self, num_moves):
pass
def is_solved(self):
pass
def copy(self):
pass
def successors(self):
pass
# Required
def find_solutions_iddfs(self):
pass
# Required
def find_solution_a_star(self):
pass

Step by step
Solved in 5 steps with 2 images









