Exemplo n.º 1
0
def getProblem():
    # validate arguments
    if len(sys.argv) != 4:
        print "ERROR: invalid arguments"
        print "usage: rows cols seed"
        exit(0)

    # read arguments
    rows = int(sys.argv[1])
    cols = int(sys.argv[2])
    seed = int(sys.argv[3])

    # return random generator problem
    generator = ProblemGenerator()
    problem = generator.generate(rows, cols, seed)
    return problem
Exemplo n.º 2
0
def getProblem():
    # validate arguments
    if len(sys.argv) != 4:
        print "ERROR: invalid arguments"
        print "usage: rows cols seed"
        exit(0)

    # read arguments
    rows = int(sys.argv[1])
    cols = int(sys.argv[2])
    seed = int(sys.argv[3])

    # return random generator problem
    generator = ProblemGenerator()
    problem = generator.generate(rows, cols, seed)
    return problem
Exemplo n.º 3
0
    def __init__(self, parser, perception_func):

        self.parser = parser
        self.perception = Perception(perception_func)
        self.pddl = self.parser
        self.goal_tracking = GoalTracking(self.parser, self.perception)
        self.problem_generator = ProblemGenerator(self.perception, self.parser,
                                                  "tmp_problem_generation")

        self.valid_actions = TrackedSuccessorValidActions(
            self.pddl, self.problem_generator, self.goal_tracking)

        self.on_action_observers = [
            self.goal_tracking.on_action, self.valid_actions.on_action,
            self.perception.on_action
        ]
Exemplo n.º 4
0
    def __init__(self, parser, perception):

        self.parser = parser
        self.perception = perception
        self.pddl = PDDL(parser.domain_path, parser.problem_path)
        self.goal_tracking = GoalTracking(self.parser, self.perception)
        self.problem_generator = ProblemGenerator(self.perception, self.parser,
                                                  "tmp_problem_generation")
        self.action_simulator = ActionSimulator(self.parser, self.perception)

        self.valid_actions = TrackedSuccessorValidActions(
            self.pddl, self.problem_generator, self.goal_tracking)

        self.on_action_observers = [
            self.goal_tracking.on_action, self.valid_actions.on_action,
            self.perception.on_action
        ]
Exemplo n.º 5
0
    def __init__(self, parser, perception_func, planner=None):

        self.parser = parser
        self.planner = planner or make_plan
        self.perception = Perception(perception_func)
        self.pddl = self.parser
        self.goal_tracking = GoalTracking(self.parser, self.perception)
        self.problem_generator = ProblemGenerator(self.perception, self.parser,
                                                  "tmp_problem_generation")

        self.valid_actions = ValidActions(self.pddl, self.perception,
                                          self.problem_generator,
                                          self.goal_tracking)

        self.on_action_observers = [
            self.goal_tracking.on_action, self.valid_actions.on_action,
            self.perception.on_action
        ]
Exemplo n.º 6
0
import argparse
from problem_generator import ProblemGenerator


if __name__ == '__main__':
    parser = argparse.ArgumentParser()

    parser.add_argument('type', type=str)
    parser.add_argument('name', type=str)

    args = parser.parse_args()

    pg = ProblemGenerator(
        problem_type=args.type,
        problem_name=args.name,
        problem_description=''
    )

    if pg.check_problem_solved():
        print 'Problem {} solved'.format(pg)
        pg.save_db()
Exemplo n.º 7
0
import argparse
from problem_generator import ProblemGenerator


if __name__ == '__main__':
    parser = argparse.ArgumentParser()

    parser.add_argument('description', type=str, help='Problem description')
    parser.add_argument('-t', '--type', type=str, default='')
    parser.add_argument('-n', '--name', type=str, default='')

    args = parser.parse_args()

    pg = ProblemGenerator(
        problem_type=args.type,
        problem_name=args.name,
        problem_description=args.description
    )

    pg.create_new_problem()
Exemplo n.º 8
0
import argparse
from problem_generator import ProblemGenerator


if __name__ == '__main__':
    parser = argparse.ArgumentParser()

    parser.add_argument('type', type=str)
    parser.add_argument('name', type=str)

    args = parser.parse_args()

    pg = ProblemGenerator(
        problem_type=args.type,
        problem_name=args.name
    )

    pg.del_entry_from_db()
Exemplo n.º 9
0
from problem_generator import ProblemGenerator


if __name__ == "__main__":

    yn = raw_input("Are you sure you want to clear the database? y/n\n")

    if yn.lower() == "y":
        print "Cleared db"
        ProblemGenerator.clear_db()
    else:
        print "OK. We won't touch it then!"
from problem_generator import ProblemGenerator


if __name__ == '__main__':
    db = ProblemGenerator.get_db(
        ProblemGenerator.get_db_path()
    )

    unsolved = []

    for problem in db:
        if not problem['solved']:
            unsolved.append(problem)

    print 'There are {} unsolved problems'.format(len(unsolved))
    for problem in unsolved:
        print '- {} / {} / {}'.format(problem['type'], problem['name'], problem['description'])