

Position = ĭef move_up(self, configuration):# The configuration passed to it is the new configuration Global node_id # Made it Global because everytime its called means we are creating a new_nodeĬonfig = self._get_old_configuration(configuration) # returns new_configuration: 123045678node_id node_id is a number String_new_configuration = str(new_configuration)įor element in string_new_configuration:ĭef _get_new_configuration(self, old_configuration): Old_configuration = self._get_old_configuration(configuration)ĭef _get_old_configuration(self, new_configuration):

String_orientation = string_configurationĭef display_board(self, configuration, arg='new'):

String_node_id = string_configurationĭef get_node_orientation(self, configuration): String_configuration = str(configuration) Self.start_configuration = str(start_board) + '0'ĭef get_node_id(self, configuration):#configuration: 123405786999 implies Node 999 Missing tile space is moved to form a regular pattern such 12345678_, where '_' denotes the missing tileįrom collections import deque, namedtuple The puzzle also exists in other sizes, particularly the smaller 8-puzzle. Initially I was working with a format for board as: ,]īut after some suggestions, I changed it to '123456708'ĭescription of 8-Puzzle Problem: The 15-puzzle (also called Gem Puzzle, Boss Puzzle, Game of Fifteen, Mystic Square and many others) is a sliding puzzle that consists of a frame of numbered square tiles in random order with one tile missing. The code works for very simple puzzle configuration but freaks out when the even a modest puzzle is input to it. I am new to programming and I am trying to solve the 8-puzzle using brute force algorithm.
