restspring.blogg.se

Prolog block world problem
Prolog block world problem












prolog block world problem

There is a block (or chair) present in the room near the window. Problem StatementĪ hungry monkey is in a room, and he is near the door.īananas have been hung from the center of the ceiling of the room. Given two lists `As` and `Bs`, `substitute/4` will substitute every term `A` in `As` with `B` to produce `Bs`.In this prolog example, we will see one very interesting and famous problem, The Monkey and Banana Problem. Substitute(on(Block, _), Source, on(Block, Destination), Target). Perform(Source, move(Block, Destination), Target) :. This clause is responsible for changing the `Source` state into the `Target` state by performing an `Action`. nothing in on `Destination`.Īction(State, move(Block, Destination)) :-Īction(, move(a, q)).

#Prolog block world problem free#

`Destination` is free to move to in this state. All actions are of the form `move(Block, Destination)`.Ī action `move(Block, Destination)` is legal ifģ. This clause is responsible for determining the legal actions in a state. 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.

prolog block world problem

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. 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 This notebook explores () Stanford Research Institute Problem Solver.














Prolog block world problem