fokiebooks.blogg.se

Prolog block world problem
Prolog block world problem













prolog block world problem

In this section we will take a look at the definition of these clauses. The `strips/4` clause is defined in terms of `action/2` and `perform/3`. Strips(Initial, Final, Plan) :- strips(Initial, Final,, Plan).ĭeepening_strips(1, Initial, Final, Visited, Plan).ĭeepening_strips(Bound, Initial, Final, Visited, Plan) :-īounded_strips(Bound, Initial, Final, Visited, Plan).ĭeepening_strips(Successor, Initial, Final, Visited, Plan).īounded_strips(Bound, Initial, Final, Visited, ) :-īounded_strips(Predecessor, Intermediate, Final,, Actions). Since Prolog out of the box does a depth first search, we are not guaranteed to find the shortest plan first. In general we will favor shorter plans over longer plans. In order to prevent the revisiting intermediate states, we keep track of the visited intermediate states. The reason for this is that Prolog would happily move a to b, and back again ad infinitum. With the above considerations it is not garantueed that Prolog can find a solution. In that case we perform any legal action to an intermediate state and try to reach the `Final` state from there. The `strips/3` clause does the heavy lifting of coming up with a plan. Solve(Initial, Final, Plan) :- strips(Initial, Final, Plan). We delegate the actual solving to our implementation of STRIPS. We will introduce a top-level term that allows us to come up with a plan to go from an `Initial` state to a `Final` state. "p", "q", "r".Īs an example the state above is represented as "a", "b", "c", and `Y` can either be a block or a place on the table, e.g. We will represent a state in the blocks world as a list of terms `on(X, Y)`. Our world has three blocks: a, b, c, and three places on the table: p, q, r. Moreover, some kinds of blocks cannot have other blocks stacked on top of them. Because of this, any blocks that are, at a given time, under another block cannot be moved. Only one block may be moved at a time: it may either be placed on the table or placed atop another block.

prolog block world problem

The goal is to build one or more vertical stacks of blocks. A set of wooden blocks of various shapes and colors sitting on a table. > one of the most famous planning domains in artificial intelligence. > an automated planner developed by Richard Fikes and Nils Nilsson Makes sense, but then I tried: ?-bottomBlock(X).This notebook explores () Stanford Research Institute Problem Solver. So I tried this, which is practically the same thing: bottomBlock(X) :- \+ above(X, _).ĮxactlyThree(X) :- above(X, Y), above(Y, Z), above (Z, W), bottomBlock(W). So X has exaclty three blocks beneath it if X is above a block Y, if Y is above a block Z, if Z is above a block W and block W is not above any block. So I started with: exactlyThree(X) :- above(X, Y), above(Y, Z), above (Z, W), \+ above(W, _). So now I want to define a predicate that tells me if a certain block has exactly 3 blocks beneath it. So one block is above another block if there's some block beneath it that is on top of that block. I have a bunch of blocks, labeled a to f, and they're all stacked on top of each other, a being at the bottom and f all the way on top. I'm trying to do something very simple in Prolog, but for some reason it's not working and I can't figure out why.















Prolog block world problem