Пример #1
0
 def create_rooms(self, init_seed, count, width_t, height_t, robots_t, dirt_piles_t, simple_obs_t, complex_obs_t, complex_obs_size_t, ):    
     print "Creating Rooms for", init_seed
     rnd = Random(init_seed)
     generated = 0
     tries = 0
     while generated < count and tries < 10000:
         tries += 1
         seed = rnd.randint(0, sys.maxint)
         room_tup = problems.randomRoom2(width_t, height_t, robots_t, dirt_piles_t, simple_obs_t, complex_obs_t, complex_obs_size_t, seed)
         if room_tup == None:
             continue
         room_id, room = room_tup
         if not is_room_solvable(room):
             continue
         self.rooms[room_id] = room
         generated += 1
     print "Finished Creating Rooms"
Пример #2
0

class SolveAgent(ProblemAgent):
    def __init__(self):
        self.heuristic = heuristics.PowerHeuristic2()
        self.algo = AnytimeBeamSearch(10, (1.2, "exp"))

    def getHeuristic(self):
        return self.heuristic

    def solve(self, problem_state, time_limit):
        return self.algo.find(problem_state, self.heuristic, time_limit)


#problem = room_problems.all_static_rooms['linear_test']
problem = problems.randomRoom2((10, 12), (10, 12), (3, 4), (3, 4), (10, 15),
                               (1, 2), (6, 10), 4)
#problem = rooms.randomRoom(9, 9, 6, 15, 20, 3)  very interesting room
#problem = rooms.complexRoom2()

print "Start"
print problem

agent = SolveAgent()
start = time.clock()
solution = agent.solve(problem, 10)[0]
run_time = time.clock() - start

if solution == None:
    print 'Running time:', run_time
    print "No solution found"
else:
Пример #3
0
from anytime_beam_search import AnytimeBeamSearch
import problems

class SolveAgent(ProblemAgent):
    def __init__(self):
        self.heuristic = heuristics.PowerHeuristic2()
        self.algo = AnytimeBeamSearch(10,(1.2,"exp"))

    def getHeuristic(self):
        return self.heuristic

    def solve(self, problem_state, time_limit):
        return self.algo.find(problem_state, self.heuristic, time_limit)

#problem = room_problems.all_static_rooms['linear_test']
problem = problems.randomRoom2((10,12), (10,12), (3,4), (3,4), (10,15), (1,2), (6,10), 4)
#problem = rooms.randomRoom(9, 9, 6, 15, 20, 3)  very interesting room
#problem = rooms.complexRoom2()

print "Start"
print problem

agent = SolveAgent()
start = time.clock()
solution = agent.solve(problem, 10)[0]
run_time = time.clock() - start

if solution == None:
    print 'Running time:', run_time
    print "No solution found"
else: