We need to think of what must be true of the world prior to the application of the operator, what will be true after it's application, and what will no longer be true. Let's define a simple version of stack(a, b). The state is affected by the add and delete lists of the operators. and X will be instanced with a list of operators needed to be applied to the initial state to have it result in the goal state. You also need a goal state, which we will define as such:Īt run time, you can call ?- pln(,, X). This list would be a parameter to your top level planning predicate, let's call it pln for short. Start off with the canonical world state, all blocks are on the table, with none stacked: Your operators each have an add and delete list which modifies the world state list via the apply predicate when they are applied. Basically, your world state is kept in a Prolog list. Yes, I kind of hinted at it in my post (not wanting to spoil the problem for you too much). I'm a bit rusty with Prolog, but if you still need help then ask. precondition: ae (armEmpty), on(x, table), clear(x).All blocks are the same size, and you can't pick up a block that's underneath another block. The program then works out how to get from the initial state to the goal state. I think he means that game that gets distributed as "Mahjong" even though it's nothing to do with the actual real-world game of that name (except for the appearance of the "tiles").No, he means the blocks world problem: you start with an arbitrary initial state, and have an arbitrary goal state. You can do this by working backwards from the goal state. You then need to find a way of taking a start state and a goal state and applying a set of operators to the initial state to result in the goal state. It's simple to write a predicate that applies an operator to the current state:Īpply(Rule, State, NewState) :- p_op(Rule, Pre, Add, Del), subset(Pre, State), union(State, Add, TState), subtract(Del, TState, NewState). This takes two blocks and stacks them on top of one another, providing that they are both "clear" (it's a simplified world representation, so don't blame me if there's faults in it :-)). These operators have a list of preconditions that must be true of the world before they can be applied, an additions list which adds facts to the world after they have been applied, and a deletion list which deletes facts from the world after they have been applied. If it's the latter, then that is quite easy (I'll show you a simple STRIPS like system):ĭefine some operators. Prolog facts are expressed in definite pattern.Do you wish to make a game, or do you wish to make a planning system which will take an initial state and a goal state and generate a plan to move the blocks so that they are in the goal state? So, Knowledge Base can be considered similar to database, against which we can query. We get output as affirmative if our query is already in the knowledge Base or it is implied by Knowledge Base, otherwise we get output as negative. These facts constitute the Knowledge Base of the system. Differences between Procedural and Object Oriented Programming.Arrow operator -> in C/C++ with Examples.Modulo Operator (%) in C/C++ with Examples.Inorder Tree Traversal without Recursion.Tree Traversals (Inorder, Preorder and Postorder).Breadth First Search or BFS for a Graph.Unique paths covering every non-obstacle block exactly once in a grid.Print all possible paths from top left to bottom right of a mXn matrix.Count all possible paths from top left to bottom right of a mXn matrix.Count number of ways to reach destination in a Maze.The Knight’s tour problem | Backtracking-1.Warnsdorff’s algorithm for Knight’s tour problem.Printing all solutions in N-Queen Problem.Difference between Informed and Uninformed Search in AI.Understanding PEAS in Artificial Intelligence.Uniform-Cost Search (Dijkstra for large Graphs).Introduction to Hill Climbing | Artificial Intelligence.ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |