Example #1
0
def travel_m(state,goal):
    x=state.location_car
    y=goal.final
    if x!=y:
        z=select_new_city(state,y)
        g=pyhop.Goal('g')
        g.final=y
        return [('travel_op',z), ('travel_to_city',g)]
    return False
def get_goal():
    goal = pyhop.Goal('goal')
    goal.days = {
    }  # Outer array: Day of week, Inner array: Time of day, Value: # of pills present
    goal.days['green'] = [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0,
                                                       0], [1, 0, 0, 0],
                          [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]]
    goal.days['blue'] = [[0, 2, 0, 0], [0, 0, 0, 0], [2, 0, 0,
                                                      0], [0, 0, 0, 0],
                         [2, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
    #goal.light = 'on'
    return goal
Example #3
0
	state.num_victims -= 1;
	return state;

def call_success(state, goal):
	for a in state.ambulances.items():
		print(a[0], ": ", a[1]["t"]);
	
	if(state.num_victims <= 0):
		print("Success!!");
		return [];
	else:
		return False;



#############################PYHOP############################
state1			= pyhop.State("state1");

state1.hospitals	= hospitals;
state1.ambulances	= ambulances;
state1.victims		= victims;
state1.num_victims	= len(victims);

goal1			= pyhop.Goal("goal1");
goal1.num_victims	= 0;

pyhop.declare_operators(move_ambulance, enter_ambulance, exit_ambulance);
pyhop.declare_methods('save_the_victims', save_victim, call_success);

pyhop.pyhop(state1,[('save_the_victims', goal1)], verbose=1);
state1.phoned_times = {'me':0, 'you':0}     # how many times "me" has phoned
state1.wants_taxi = {'me':True, 'you':True} # does "me" want a taxi?
state1.waiting_time = {'me':0, 'you':0}     # waiting time for a taxi of "me"
state1.read_book = {'me':False, 'you':True} # has "me" read the book?


# Distribucion de las distancias

state1.dist = {'home':{'park':8, 'university':10}, 'park':{'home':8, 'university':6}, 
               'university':{'home':10, 'park':6}}



# Definicion del objetivo

goal1 = pyhop.Goal('goal1')
goal1.loc = {'me':'park', 'you':'university'}


print("""
********************************************************************************
Call pyhop.pyhop(state1,[('travel','me','home','park')]) with different verbosity levels
********************************************************************************
""")

# Buscamos un plan a partir de un estado inicial para que "me" viaje de "home" a "park"

# pyhop.pyhop(state1, [('travel','me','home','park')], verbose=1)
pyhop.pyhop(state1, [('travel', goal1)], verbose=1)

Example #5
0
        state.isOnStack = {}
    state.isOnStack.update({c: is_stacked for c in cubes})


state1_h = pyhop.State("state1_h")
state1_h.cubes = ["cube1", "cube2", "cube3", "cube4", "cube5", "cube6"]
make_reachable_by(state1_h, state1_h.cubes[:3], ["human"])
make_reachable_by(state1_h, state1_h.cubes[3:], ["robot"])
make_reachable_by(state1_h, state1_h.cubes[0:1], ["human", "robot"])
put_on_stack(state1_h, state1_h.cubes, False)
state1_h.isCarrying = {"human": None, "robot": None}
state1_h.onStack = []

state1_r = deepcopy(state1_h)

goal1_h = pyhop.Goal("goal1_h")
goal1_h.isOnStack = {"cube4": True, "cube1": True, "cube6": True}
goal1_h.onStack = ["cube4", "cube1", "cube6"]
goal1_r = deepcopy(goal1_h)

pyhop.set_state("human", state1_h)
pyhop.add_tasks("human", [('stack', goal1_h)])
pyhop.set_state("robot", state1_r)
pyhop.add_tasks("robot", [('stack', goal1_r)])

pyhop.print_state(pyhop.agents["human"].state)

sol = []
plans = pyhop.seek_plan_robot(pyhop.agents, "robot", sol)
rosnode = None