![]() The actions are then applied to the current state, producing a new set of states. The JSON is then processed to identify applicable actions within a given state of the problem. ![]() The domain and problem PDDL files are parsed via PEG.js, producing a JSON object for a given domain. The AI planning works by processing a simple domain using a PEG.js grammar sheet and runs the result using a simple STRIPS problem. Several examples from the Blocks World domain are included in this project, in which the AI is able to successfully plan the series of steps to move and stack blocks on a series of tables. For example, stacking blocks, Towers of Hanoi, and even Starcraft can be solved by the AI (see below, it's pretty neat!). The following examples show how to solve planning problems by identifying the optimal set of actions to achieve a goal. If you're new to STRIPS automated planning, here is a great tutorial to get you started. At top level, call ANGELIC -SEARCH with as the initialPlan. The predicate MAKING-PROGRESS checks to make sure that we aren’t stuck in an infinite regression of refinements. clauses return state def angelic_search ( problem, hierarchy, initialPlan ): """ A hierarchical planning algorithm that uses angelic semantics to identify and commit to high-level plans that work while avoiding high-level plans that don’t. parent, sequence )) def result ( state, actions ): """The outcome of applying an action to the current problem""" for a in actions : if a. refinements ( hla, outcome, hierarchy ): print ( "." ) frontier. path () else : print ( "else" ) for sequence in Problem. result ( problem, prefix ) if hla is None : if outcome. action # prefix, suffix = subseq(plan.state, hla) outcome = Problem. state # first_or_null(plan) prefix = None if plan. append ( act ) while True : if not frontier : return None plan = frontier. append ( HLA ( library, precond, effect )) yield actions def hierarchical_search ( problem, hierarchy ): """ 'Hierarchical Search, a Breadth First Search implementation of Hierarchical Forward Planning Search' The problem is a real-world problem defined by the problem class, and the hierarchy is a dictionary of HLA - refinements (see refinements generator for details) """ act = Node ( problem. name ] for i in indices : actions = for j in range ( len ( library )): # find the index of the step of the HLA index_step = ) if x = library ] precond = library # preconditions of step effect = library # effect of step actions. name = action_name ) if list_action is None : raise Exception ( "Action ' """ e = Expr ( hla. args list_action = first ( a for a in self. Note that action is an Expr like expr('Remove(Glass, Table)') or expr('Eat(Sandwich)') """ action_name = action. goals ) def act ( self, action ): """ Performs the action given as argument. append ( clause ) return new_clauses def goal_test ( self ): """Checks if the goals have been reached""" return all ( goal in self. actions = actions def convert ( self, clauses ): """Converts strings into exprs""" if not isinstance ( clauses, Expr ): if len ( clauses ) > 0 : clauses = expr ( clauses ) else : clauses = try : clauses = conjuncts ( clauses ) except AttributeError : clauses = clauses new_clauses = for clause in clauses : if clause. """ def _init_ ( self, init, goals, actions ): self. The conjunction of these logical statements completely defines a state. It stores states in a knowledge base consisting of first order logic statements. Class PlanningProblem : """ Planning Domain Definition Language (PlanningProblem) used to define a search problem.
0 Comments
Leave a Reply. |