def wrapping_move_action_string(self, state, wrap_col = False): puzzle = XPuzzle(self.rows, self.cols, state) tile_moved = puzzle.wrapping_move(wrap_col) if( tile_moved != -1): return {'key': puzzle.current_state_to_string(), 'tile_moved': tile_moved} else: return -1
def diagonal_move_action_string(self, state, is_wrapping): puzzle = XPuzzle(self.rows, self.cols, state) tile_moved = puzzle.diagonal_move(is_wrapping) if( tile_moved != -1): return {'key': puzzle.current_state_to_string(), 'tile_moved': tile_moved} else: return -1
def normal_move_action_string(self, state, action): puzzle = XPuzzle(self.rows, self.cols, state) tile_moved = puzzle.regular_move(action) if( tile_moved != -1): return {'key': puzzle.current_state_to_string(), 'tile_moved': tile_moved} else: return -1
def reset(self, initial_state): self.close_list = PriorityQueue() self.open_list = PriorityQueue() self.puzzle = XPuzzle(self.rows, self.columns, initial_state) self.initial_state = (0, copy.deepcopy(self.puzzle.arr), 0, 0, 0, 0, None, 0) self.is_goal_state = False self.ignore_move = '' self.search_space = {}
def __init__(self, puzzle, rows, columns): #self.read_input_file(filename) self.inputs = [puzzle] self.goal_state1 = [[ '1', '2', '3', '4', ], ['5', '6', '7', '0']] self.goal_state2 = [['1', '3', '5', '7'], ['2', '4', '6', '0']] #self.heuristics = ['h1', 'h2', 'h0'] self.heuristics = ['h1', 'h2'] self.heuristic = '' self.rows = 2 self.columns = 4 self.puzzle = XPuzzle(self.rows, self.columns, puzzle) #self.goal_state1 = [['1', '2', '3', '4',],['5', '6', '7', '8'],['9','10','11','0']] #self.goal_state2 = [['1', '4', '7', '10'],['2','5','8','11'],['3','6','9','0']] self.analysis = {}