def move_left(self): ''' Moving the space to left :return: a new board position or None if not possible ''' # Replace 'return None' with you own code new_node = copy.deepcopy(self.board) empty_space = [] for i in range(3): for j in range(3): if new_node[i][j] == 0: empty_space.append(i), empty_space.append(j) if empty_space[1] == 2: return None else: new_node[i][j], new_node[i][j - 1] = new_node[i][j - 1], new_node[i][j] return EightGameNode(new_node) def move_right(self): ''' Moving the space to right :return: a new board position or None if not possible ''' # Replace 'return None' with you own code new_node = copy.deepcopy(self.board) empty_space = [] for i in range(3): for j in range(3): if new_node[i][j] == 0: empty_space.append(i), empty_space.append(j) if empty_space[1] == 2: return None else: new_node[i][j], new_node[i][j + 1] = new_node[i][j + 1], new_node[i][j] return EightGameNode(new_node) def move_up(self): ''' Moving the space up :return: a new board position or None if not possible ''' # Replace 'return None' with you own code new_node = copy.deepcopy(self.board) empty_space = [] for i in range(3): for j in range(3): if new_node[i][j] == 0: empty_space.append(i), empty_space.append(j) if empty_space[1] == 2: return None else: new_node[i][j], new_node[i - 1][j] = new_node[i - 1][j], new_node[i][j] return EightGameNode(new_node) def move_down(self): ''' Moving the space down :return: a new board position or None if not possible ''' # Replace 'return None' with you own code new_node = copy.deepcopy(self.board) empty_space = [] for i in range(3): for j in range(3): if new_node[i][j] == 0: empty_space.append(i), empty_space.append(j) if empty_space[1] == 2: return None else: new_node[i][j], new_node[i + 1][j] = new_node[i + 1][j], new_node[i][j] return EightGameNode(new_node)