예제 #1
0
    def __init__(self, initial, goal=None):
        '''Inicializacion de nuestro problema.'''
        Problem.__init__(self, initial, goal)

        # Las acciones son movimientos de determinadas piezas:
        #
        # Movimientos horizontales
        # a1xa2
        # a2xa3
        # b1xb2
        # b2xb3
        # c1xc2
        # c2xc3
        #
        # Movimientos verticales
        # a1xb1
        # b1xc1
        # a2xb2
        # b2xc2
        # a3xb3
        # b3xc3

        self._actions = [
                            ('a1xa2', (0,0), (0,1)), ('a2xa3', (0,1), (0,2)), ('b1xb2', (1,0), (1,1)), ('b2xb3', (1,1), (1,2)), ('c1xc2', (2,0), (2,1)), ('c2xc3', (2,1),(2,2)),
                            ('a1xb1', (0,0), (1,0)), ('b1xc1', (1,0), (2,0)), ('a2xb2', (0,1), (1,1)), ('b2xc2', (1,1), (2,1)), ('a3xb3', (0,2), (1,2)), ('b3xc3', (1,2),(2,2))
                        ]
        self.validStates = []
        self.cantidadPastelesRicos = 0
예제 #2
0
    def __init__(self, initial, goal=(3, 3, 0, 0, 0)):
        """ Define goal state and initialize a problem
        (3, 3, 0, 0, 0)
        (M, C, M, C, B)
        """

        self.goal = goal
        Problem.__init__(self, initial, goal)
예제 #3
0
 def __init__(self, initial, goal=None, cities=None):
     """The constructor specifies the initial state, and possibly a goal
     state, if there is a unique goal.  Your subclass's constructor can add
     other arguments."""
     self.cities = cities
     self.nodes_cnt = 0
     self.citiy_num = len(cities)
     self.depth = 0
     Problem.__init__(self, initial, goal)
예제 #4
0
    def __init__(self, initial, goal=None, random_h=False):
        """The constructor specifies the initial state, and possibly a goal
        state, if there is a unique goal.  Your subclass's constructor can add
        other arguments."""
        self.random_h = random_h
        self.nodes_cnt = 0
        self.depth = 0

        Problem.__init__(self, initial, goal)
예제 #5
0
 def __init__(self, initial, goal, grid):
     Problem.__init__(self, initial, goal)
     """In the constructor we take in the initial state and goal state.
     
    """
     self.initial = initial
     self.goal = goal
     self.grid = grid
     self.max_speed = (numpy.matrix(self.grid).max())
예제 #6
0
 def __init__(self,
              inicial=(0, 0),
              meta=(34, 0),
              digits=[2, 3],
              operands=["*", "+"]):
     Problem.__init__(self, inicial, meta)
     self.initial = inicial
     for operand in operands:
         self.acciones.append(operand)
     self.digits = digits
예제 #7
0
 def __init__(self, initial, goal=None):
     """The constructor specifies the initial state, and possibly a goal
     state, if there is a unique goal.  Your subclass's constructor can add
     other arguments."""
     self.nodes_cnt = 0
     self.depth = 0
     self.states = [(3, 3, 0), (3, 0, 0), (2, 3, 0), (2, 2, 0), (2, 0, 0),
                    (1, 3, 0), (1, 1, 0), (1, 0, 0), (0, 3, 0), (0, 0, 0),
                    (3, 3, 1), (3, 0, 1), (2, 3, 1), (2, 2, 1), (2, 0, 1),
                    (1, 3, 1), (1, 1, 1), (1, 0, 1), (0, 3, 1), (0, 0, 1)]
     Problem.__init__(self, initial, goal)
예제 #8
0
 def __init__(self, initial, gridSize, maxTime, weight):
     """ Define goal state and initialize a problem """
     self.gridSize = gridSize
     self.maxTime = maxTime
     self.numEvents = len(
         [s for s in initial if isinstance(s, tuple) if 'event' in s])
     self.numCars = len(
         [s for s in initial if isinstance(s, tuple) if 'car' in s])
     self.epsilon = 0.01
     self.numSteps = 0
     self.weight = weight
     Problem.__init__(self, initial)
예제 #9
0
def main():
    rawClauses = read_stdin()
    clauseInst = Clause(rawClauses)

    resolution = Problem(initialState=[],
                         possibleActions=clauseInst.clausesList,
                         goalState=[])

    status = Search.bfs(resolution)
    print("\n{}".format(status))
예제 #10
0
파일: assignemnt3.py 프로젝트: lyj47/AI-A3
def main():
    problem = Problem('p2.txt')
    csp = CSP(problem.vars, problem.domains, problem.neighbors,
              problem.constraints)
    result = backtracking_search(csp,
                                 select_unassigned_variable=mrv,
                                 order_domain_values=lcv,
                                 inference=mac)
    for result_index in range(problem.board_length):
        row = ''
        for value_index in range(len(result[result_index])):
            row = row + str(result[result_index][value_index])
        print(row)
예제 #11
0
파일: Cars.py 프로젝트: mandrei28/Teme-AI
 def __init__(self, initial, goal=None):
     """ Define goal state and initialize a problem """
     self.goal = goal
     self.matrix_size = int(math.sqrt(len(initial)))
     self.total_iterations = 0
     self.cars = Queue(
         self.matrix_size
     )  # o coada in care salvam ordinea in care se muta masinile
     self.delta = {
         'UP': -self.matrix_size,
         'DOWN': self.matrix_size,
         'LEFT': -1,
         'RIGHT': 1,
         'JUMPLEFT': -2,
         'JUMPRIGHT': 2,
         'JUMPDOWN': 2 * self.matrix_size,
         'JUMPUP': -2 * self.matrix_size,
         'STAY': 0
     }
     for i in range(1, self.matrix_size + 1):
         self.cars.put(i)  # umplem coada cu masini de la 1 la matrix_size+1
     Problem.__init__(self, initial, goal)
예제 #12
0
    def __init__(self, initial, goal, map, diagonal_moves=False, shuffle_actions_list=False):
        assert(index_by(initial, map) == START)
        assert(index_by(goal, map) == GOAL)

        self.map    = map
        self.height = len(map) # number of rows (m)
        self.width  = len(map[0]) # number of columns (n)

        self.initial = initial
        self.goal = goal

        self.diagonal_moves = diagonal_moves
        self.shuffle_actions_list = shuffle_actions_list

        if diagonal_moves:
            self.directions = [(-1, -1), (-1,  0), (-1,  1),
                               ( 0, -1),           ( 0,  1),
                               ( 1, -1), ( 1,  0), ( 1,  1)]
        else:
            self.directions = [          (-1,  0),
                               ( 0, -1),           ( 0,  1),
                                         ( 1,  0),         ]

        Problem.__init__(self, self.initial, self.goal)
예제 #13
0
 def __init__(self, initial, goal):
     self.goal = goal
     self.initial = initial
     self.visited_states = []
     Problem.__init__(self, self.initial, self.goal)
예제 #14
0
파일: mysearch.py 프로젝트: pealan/mc906
 def __init__(self, initial, goal, matrix, heuristic=1):
     Problem.__init__(self, initial, goal)
     self.matrix = matrix
     self.heuristic = heuristic
예제 #15
0
 def __init__(self, initial):
     size = len(initial)
     Problem.__init__(self, initial, goal=bytes((1, ) * size))
     self.transform_map = build_transform_map(int(sqrt(size)))
     self._actions = tuple(range(size))
예제 #16
0
    def __init__(self, init):
        #self.old_tables = {}
        #self.best_value = 0

        Problem.__init__(self, get_init_state_from_file(init))
예제 #17
0
 def __init__(self, initial=(0, 0), goal=(30, 30), obstacles=(), **kwds):
     Problem.__init__(self, initial=initial, goal=goal, **kwds)
     self.obstacles = obstacles - {initial, goal}
예제 #18
0
 def __init__(self, initial, goal, image):
     self.initial = initial
     self.goal = goal
     self.image = image
     Problem.__init__(self, initial, goal)
예제 #19
0
 def __init__(self, domain_problem):
     self.dp = domain_problem
     self.goals = {tuple(atom.predicate) for atom in self.dp.goals()}
     initial = tuple([tuple(atom.predicate) for atom in self.dp.initialstate()])
     Problem.__init__(self, initial)
예제 #20
0
 def value(self):
     Problem.value(self)
예제 #21
0
    def __init__(self, init):
        #self.old_tables = {}
        #self.best_value = 0

        Problem.__init__(self, get_init_state_from_file(init))
예제 #22
0
 def __init__(self, initial, m, n, x, goal=None):
     Problem.__init__(self, initial, goal)
     self.m = m
     self.n = n
     self.x = x
예제 #23
0
 def __init__(self, initial, goal=None):
     """Inicializacion de nuestro problema."""
     Problem.__init__(self, initial, goal)
     # cada accion tiene un texto "lindo", y despues una tupla con la
     # cantidad de misioneros y canibales que se mueven en la canoa
     self._actions = [("1c", (0, 1)), ("1m", (1, 0)), ("2c", (0, 2)), ("2m", (2, 0)), ("1m1c", (1, 1))]
 def __init__(self, N):
     self.N = N
     self.initial = tuple([-1] * N)
     Problem.__init__(self, self.initial)
예제 #25
0
 def __init__(self, initial, goal, graph, heuristics):
     Problem.__init__(self, initial, goal)
     self.graph = graph
     self.heuristics = heuristics
예제 #26
0
 def __init__(self, init_state, final_state, board_size):
     Problem.__init__(self, init_state, final_state)
     self.board_size = board_size
 def __init__(self, initial, goal, graph):
     Problem.__init__(self, initial, goal)
     self.graph = graph
예제 #28
0
 def __init__(self, initial, goal):
     Problem.__init__(self, initial, goal)
예제 #29
0
파일: P2.py 프로젝트: mandrei28/Teme-AI
    def __init__(self, initial, goal=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0)):
        """ Define goal state and initialize a problem """

        self.goal = goal
        Problem.__init__(self, initial, goal)
예제 #30
0
 def __init__(self, inicial=(2, 3, 0), meta=(2, 3, 13)):
     Problem.__init__(self, inicial, meta)
     self.acciones = ["+A", "+B", "*A", "*B"]
예제 #31
0
 def __init__(self, initial=[], goal=[], size=5):
     Problem.__init__(self, initial, goal)
     self.size = size
예제 #32
0
 def __init__(self, initial, goal):
     Problem.__init__(self, initial, goal)
예제 #33
0
 def __init__(self, init_state, final_state, max_qty):
     Problem.__init__(self, init_state, final_state)
     self.max_qty = max_qty
예제 #34
0
 def __init__(self, initial, goal):
     self.goal = goal
     self.initial = initial
     Problem.__init__(self, self.initial, self.goal)
 def __init__(self, initial, goal):
     Problem.__init__(self, initial, goal)
     self.all_actions = [
         MissionariesLeftToRight(1),
         MissionariesLeftToRight(2)
     ]