Ejemplo n.º 1
0
def moveb_m(state,goal):
    """
    This method implements the following block-stacking algorithm:
    If there's a block that can be moved to its final position, then
    do so and call move_blocks recursively. Otherwise, if there's a
    block that needs to be moved and can be moved to the table, then 
    do so and call move_blocks recursively. Otherwise, no blocks need
    to be moved.
    """
    for b1 in all_blocks(state):
        s = status(b1,state,goal)
        if s == 'move-to-table':
            return [('move_one',b1,'table'),('move_blocks',goal)]
        elif s == 'move-to-block':
            return [('move_one',b1,goal.pos[b1]), ('move_blocks',goal)]
        else:
            continue
    #
    # if we get here, no blocks can be moved to their final locations
    b1 = pyhop.find_if(lambda x: status(x,state,goal) == 'waiting', all_blocks(state))
    if b1 != None:
        return [('move_one',b1,'table'), ('move_blocks',goal)]
    #
    # if we get here, there are no blocks that need moving
    return []
Ejemplo n.º 2
0
def moveb_m(state,goal):
    """
    This method implements the following block-stacking algorithm:
    If there's a block that can be moved to its final position, then
    do so and call move_blocks recursively. Otherwise, if there's a
    block that needs to be moved and can be moved to the table, then 
    do so and call move_blocks recursively. Otherwise, no blocks need
    to be moved.
    """
    for b1 in all_blocks(state):
        s = status(b1,state,goal)
        if s == 'move-to-table':
            return [('move_one',b1,'table'),('move_blocks',goal)]
        elif s == 'move-to-block':
            return [('move_one',b1,goal.pos[b1]), ('move_blocks',goal)]
        else:
            continue
    #
    # if we get here, no blocks can be moved to their final locations
    b1 = pyhop.find_if(lambda x: status(x,state,goal) == 'waiting', all_blocks(state))
    if b1 != None:
        return [('move_one',b1,'table'), ('move_blocks',goal)]
    #
    # if we get here, there are no blocks that need moving
    return []
Ejemplo n.º 3
0
def moveb_m(state, goal):
    """
    This method implements the following block-stacking algorithm:
    If there's a block that can be moved to its final position, then
    do so and call move_blocks recursively. Otherwise, if there's a
    block that needs to be moved and can be moved to the table, then
    do so and call move_blocks recursively. Otherwise, no blocks need
    to be moved.
    """
    blocks = blocks_according_to_goal(state, goal)
    #print(blocks)
    for b1 in blocks:
        s = status(b1, state, goal)
        #	print("status for block" + str(b1) + "is " + str(s))
        if s == 'move-to-table':
            return [('move_one', b1, 'table'), ('move_blocks', goal)]
        elif s == 'move-to-block':
            return [('move_one', b1, goal.pos[b1]), ('move_blocks', goal)]
        elif s == 'move-to-block-with-mortar':
            return [('move_one_mortar', b1, goal.pos[b1]),
                    ('move_blocks', goal)]
        elif s == 'get-from-store':
            return [('move_from_store', b1, goal.pos[b1]),
                    ('move_blocks', goal)]
        else:
            continue
    #
    # if we get here, no blocks can be moved to their final locations
    b1 = pyhop.find_if(lambda x: status(x, state, goal) == 'waiting',
                       all_blocks(state))
    if b1 != None:
        return [('move_one', b1, 'table'), ('move_blocks', goal)]
    #
    # if we get here, there are no blocks that need moving
    return []