예제 #1
0
파일: Transporte.py 프로젝트: brandres/SIN
                                        y = meta.posicion[estado.conduce[a]]
                                    else:
                                        y = camion_cercano(estado, a, x)
                if get_carga_no_gestionada(estado, x) != 'null' or camion_cercano(estado, a,
                                                                                  x) != 'null' or x != y or \
                        estado.conduce[a] != '':
                    return [('moverse', a, x, y),
                            ('realizar_transporte', meta)]
    return []


pyhop.declare_methods('realizar_transporte', realizar_transporte)
print('')
pyhop.print_methods()

estado1 = pyhop.State('estado1')
estado1.conexion = {
    'C0': {
        'P_01': "senda",
        'C1': "carretera",
        'C2': "carretera"
    },
    'C1': {
        'C0': "carretera",
        'P_12': "senda",
        'C2': "carretera",
        'P01': "senda"
    },
    'C2': {
        'C0': "carretera",
        'C1': "carretera",
예제 #2
0
    if state.dist[x][y] <= 2:
        return [('walk', a, x, y)]
    return False


def travel_by_taxi(state, a, x, y):
    if state.cash[a] >= taxi_rate(state.dist[x][y]):
        return [('call_taxi', a, x), ('ride_taxi', a, x, y), ('pay_driver', a)]
    return False


pyhop.declare_methods('travel', travel_by_foot, travel_by_taxi)
print('')
pyhop.print_methods()

state1 = pyhop.State('state1')
state1.loc = {'me': 'home'}
state1.cash = {'me': 20}
state1.owe = {'me': 0}
state1.dist = {'home': {'park': 8}, 'park': {'home': 8}}

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

print(
    "- If verbose=0 (the default), Pyhop returns the solution but prints nothing.\n"
)
pyhop.pyhop(state1, [('travel', 'me', 'home', 'park')])