def __init__(self):
        """ Class constructor. It initializes the problem with 3 missionaries and 3 cannibals
            at one side of the river. """

        initial_state = '3030L'  # Initial state

        # Call base class constructor (the initial state is specified here).
        SearchProblem.__init__(self, initial_state)

        # Define goal state.
        self.goal = '0303R'
Ejemplo n.º 2
0
    def __init__(self, initial_state):
        """ This constructor initializes the 8-puzzle game problem. """
        
        # Call base class constructor (the initial state is specified here).
        SearchProblem.__init__(self, initial_state)

        # Store game goal.
        self.goal = 'e-1-2\n3-4-5\n6-7-8';

        # Create a cache for the goal position of each piece
        self.goal_positions = {}
        self.rows_goal = string_to_list(self.goal)
        for number in 'e12345678':
            self.goal_positions[number] = get_location(self.rows_goal, number)
Ejemplo n.º 3
0
 def __init__(self, source, destination):
     SearchProblem.__init__(self, source)
     self.destination = destination
 def __init__(self, initial_problem, player_1, player_2):
     SearchProblem.__init__(self, initial_state)
     self.player_1 = player_1
     self.player_2 = player_2