Exemplo n.º 1
0
def set_max_stacks(n):
    global max_stacks
    max_stacks = n
    pyhop2.Domain()
    _current_domain.max_stacks = n
    pyhop2.declare_task_methods('move_one', m_move_one)
    pyhop2.declare_task_methods(
        'move_somewhere_else',
        *[move_to_stack_x(x) for x in range(_current_domain.max_stacks)])
    pyhop2.declare_task_methods('clear_block', m_clear_block)
    pyhop2.declare_task_methods(
        'clear_some_stack',
        *[clear_stack_x(x) for x in range(_current_domain.max_stacks)])
    pyhop2.declare_task_methods('clear_stack', m_clear_stack)
    pyhop2.declare_task_methods('pos', m_pos)
Exemplo n.º 2
0
prod = Products()
prod.seed(1)
item_list = prod.get_random_list()
item_list.append('cashier')
renderer = Renderer()

#########################################################
## Grocery Plan #########################################
# loc = {'robot': (7.4, 12.85), 'brocoli': (1.54, 5.4), 'cucumber': (1.54, 7.91), 'salt': (8.39, 4.79), 'watermelon': (5.1, 8.44), 'strawberry': (2.31, 6.36), 'potato': (3.58, 7.44), 'hamburger': (7.4, 12.85)}

domain_name = 'groceryplan'


# Create a new domain to contain the methods and operators
pyhop2.Domain(domain_name)


# states and rigid relations

rigid = pyhop2.State('rigid relations')
# These types are used by the 'is_a' helper function, later in this file
rigid.types = {
    'person':   ['robot'],
    'location': item_list}

# prototypical initial state
state0 = pyhop2.State('state0')
state0.loc = {'robot':(1,1)}
state0.cost = {'robot': 0}
Exemplo n.º 3
0
"""

# For use in debugging:
# from IPython import embed
# from IPython.terminal.debugger import set_trace

import pyhop2

# Code for use in paging and debugging
from check_result import check_result, pause, set_trace

# First, create a new domain having the same name as the current file. To do
# this, I retrieve the value of __name__, which (while this file is being
# loaded) is the filename. Thus I can copy and paste this same code into other
# files without having to change a hard-coded domain name each time.
pyhop2.Domain(__name__)

# Next, import the actions and tasks files. I thought about making them
# into a package, but ultimately decided not to. When I tried it, it made
# several things more complicated than I wanted - things that I didn't want
# to try to explain to students who have never seen packages before.

exec(f"import {__name__}_actions")  # kludge
exec(f"import {__name__}_methods")  # kludge

#############     beginning of tests     ################

print(
    '-----------------------------------------------------------------------')
print(f"Created the domain '{__name__}'. To run the examples, type this:")
print(f'{__name__}.main()')
Exemplo n.º 4
0
An expanded version of the "travel from home to the park" example in
my lectures.
Author: Dana Nau <*****@*****.**>
Feb 18, 2021
"""

import pyhop2
import random
from timeit import default_timer as timer

# For a more clever way to specify the domain name,
# see blocks_tasks.py or blocks_goals.py
domain_name = 'sequence'

# Create a new domain to contain the methods and operators
_current_domain = pyhop2.Domain(domain_name)

################################################################################
# states and rigid relations

rigid = pyhop2.State('rigid relations')
# These types are used by the 'is_a' helper function, later in this file
rigid.types = {'character': ['START', 'a', 'b', 'c', 'aa', 'bb', 'END']}
rigid.perm = {
    'START': [],
    'a': ['START'],
    'b': ['a'],
    'c': ['b', 'START'],
    'END': ['c', 'bb'],
    'aa': ['START'],
    'bb': ['aa']
Exemplo n.º 5
0
"""
This file is not really relevant to the project anymore 
since it doesn't use the procedually generated methods.
"""

import pyhop2

pyhop2.Domain('blocks_limited_stacks')
import blocks_limited_stacks_actions as act
import blocks_limited_stacks_methods
#import blocks_limited_stacks_goal_methods
import blocks_generator as gen
import blocks_limited_stacks_top_level_methods
"""
Helper methods
"""


def _apply_plan(s0, plan):
    s = s0
    for task in plan:
        action = pyhop2._current_domain._action_dict[task[0]]
        s = action(s.copy(), *task[1:])
    return s


def simple_state():
    s0 = pyhop2.State('s0')
    s0.pos = {
        'a': 'table',
        'b': 'table',