Ejemplo n.º 1
0
# define the methods
def get_img(state, direction, mode):
    instrument = state.mode[mode][0]
    return [('activate', instrument, state.on_board[instrument], direction),
            ('take_img', state.on_board[instrument], direction, instrument,
             mode)], [[0, 1]]


def activate(state, instrument, satellite, direction):
    return [('switch_off', satellite), ('switch_on', instrument, satellite),
            ('auto_calibrate', instrument)], [[0, 1], [1, 2]]


def auto_calibrate(state, instrument):
    return [('calibrate', instrument, state.on_board[instrument],
             state.calib_target[instrument])], []


new_tihtn_planner.declare_methods('get_img', get_img)
new_tihtn_planner.declare_methods('activate', activate)
new_tihtn_planner.declare_methods('auto_calibrate', auto_calibrate)

new_tihtn_planner.declare_priority({
    'get_img': 3,
    'activate': 2,
    'auto_calibrate': 1
})

new_tihtn_planner.print_methods()
Ejemplo n.º 2
0
        return [('city_ship', pkg, (copy.deepcopy(state.loc[pkg][0]), 'loc1')),
                ('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1')),
                ('city_ship', pkg, (copy.deepcopy(goal[0]), 'loc2'))], [[0, 1],
                                                                        [1, 2]]
    if state.loc[pkg][0] == goal[0] and state.loc[pkg][1] != goal[1]:
        return [('city_ship', pkg, goal)], []
    if state.loc[pkg][0] != goal[0] and goal[
            1] == 'loc1' and state.loc[pkg][1] != 'loc1':
        return [('city_ship', pkg, (copy.deepcopy(state.loc[pkg][0]), 'loc1')),
                ('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1'))], [[0, 1]]
    if state.loc[pkg][1] == 'loc1' and goal[1] == 'loc2':
        return [('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1')),
                ('city_ship', pkg, (copy.deepcopy(goal[0]),
                                    copy.deepcopy(goal[1])))], [[0, 1]]
    if goal[1] == 'loc1':
        return [('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1'))], []


new_tihtn_planner.declare_methods('air_ship', air_ship)
new_tihtn_planner.declare_methods('city_ship', city_ship)
new_tihtn_planner.declare_methods('delievery', delievery)

new_tihtn_planner.declare_priority({
    2: ['delievery'],
    1: ['city_ship', 'air_ship']
})

new_tihtn_planner.print_methods()
###################################################################################
#可见,pshop中的state的表示是通过,字典来表示的
Ejemplo n.º 3
0
            1] == 'loc2':
        return [('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1')),
                ('city_ship', pkg, (copy.deepcopy(goal[0]),
                                    copy.deepcopy(goal[1])))], [[0, 1]]
    else:
        return False, []


def delievery__5(state, pkg, goal):
    if state.loc[pkg][0] != goal[0] and state.loc[pkg][1] == 'loc1' and goal[
            1] == 'loc1':
        return [('air_ship', pkg, (copy.deepcopy(goal[0]), 'loc1'))], []
    else:
        return False, []


new_tihtn_planner.declare_methods('air_ship', air_ship)
new_tihtn_planner.declare_methods('city_ship', city_ship)
new_tihtn_planner.declare_methods('delievery', delievery__1, delievery__2,
                                  delievery__3, delievery__4, delievery__5)

new_tihtn_planner.declare_priority({
    'delievery': 2,
    'air_ship': 1,
    'city_ship': 1
})

new_tihtn_planner.print_methods()
###################################################################################
#可见,pshop中的state的表示是通过,字典来表示的
Ejemplo n.º 4
0
        return [('make_clear', block_on), ('pick_up', block_on),
                ('put_down', block_on)], [[0, 1], [1, 2]]
    else:
        return False, []


def make_clear__2(state, block):
    if (state.clear[block] == True):
        return [], []
    else:
        return False, []


new_tihtn_planner.declare_methods('tower5', tower5)
new_tihtn_planner.declare_methods('tower4', tower4)
new_tihtn_planner.declare_methods('tower3', tower3)
new_tihtn_planner.declare_methods('tower2', tower2)
new_tihtn_planner.declare_methods('tower1', tower1)
new_tihtn_planner.declare_methods('make_clear', make_clear__1, make_clear__2)

new_tihtn_planner.declare_priority({
    'tower5': 2,
    'tower4': 2,
    'tower3': 2,
    'tower2': 2,
    'tower1': 2,
    'make_clear': 1
})

new_tihtn_planner.print_methods()