def main(): p = EightPuzzle() p.shuffle(20) print(p) path, count = p.solve(h_manhattan) path.reverse() for i in path: print(i)
def main(): global default_problem global goal global goal2 puzzle = EightPuzzle(default_problem, goal) startTime = time.time() result = depth_limited_search(puzzle, 30) #result = breadth_first_tree_search(puzzle) endTime = time.time() print('solution is ', Node.solution(result)) print('path is', Node.path(result)) print('걸린 시간 :', endTime - startTime)
8: "D2-8675" } return mapping.get(robot_num) commands = [] robot_nums = set() robots = [] while True: commands = [] robot_nums = set() robots = [None for i in range(9)] board = [[1, 2, 3], [4, 5, 6], [7, 8, 0]] game = EightPuzzle(board) game.scramble(100) commands = game.find_soln() for command in commands: robot_nums.add(command[0]) print(game.get_board()) print("# of robots that need to be connected: " + str(len(robot_nums))) print("# of moves required: " + str(len(commands))) print("Enter s to start or any other key to re-scramble:") choice = input() if choice == "s": break print("Started")
def __init__(self): self.eight_puzzle = EightPuzzle()
def main(): problem2 = EightPuzzle((1, 2, 3, 4, 5, 6, 7, 8, 0), (1, 2, 3, 4, 7, 6, 8, 5, 0)) path = breadth_first_graph_search(problem2).solution() print(path, '\n')