Download presentation
Presentation is loading. Please wait.
1
CSC 8520 Spring 2013. Paula Matuszek
Lab Exercise 1 On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download them and consult planner.pl, which will in turn consult adts.pl. ?- consult('planner.pl'). % adts compiled 0.00 sec, 6,364 bytes % planner.pl compiled 0.00 sec, 11,456 bytes true. CSC 8520 Spring Paula Matuszek
2
CSC 8520 Spring 2013. Paula Matuszek
Test that it is working by typing “test.” at the prompt. You should get a list of moves. ?- test. moves are pickup(a) putdown(a) pickup(b) stack(b, c) stack(a, b) true. ?- CSC 8520 Spring Paula Matuszek
3
CSC 8520 Spring 2013. Paula Matuszek
Planner Planner is a very simple Prolog implementation of a planner using a STRIPS-like notation. A state is a list of conditions. A problem has an initial state and a goal state. For instance: the initial state for a blocks world might be: [handempty, ontable(b), ontable(c), on(a, b), clear(c), clear(a)] the goal state for the blocks world might be: [handempty, ontable(c), on(a,b), on(b, c), clear(a)] CSC 8520 Spring Paula Matuszek
4
CSC 8520 Spring 2013. Paula Matuszek
Moves A move is an action, consisting of a name, a list of preconditions, and an effect list of changes. Moves are included in the Prolog file. For example: move(pickup(X), % move name [handempty, clear(X), on(X, Y)], % preconditions [del(handempty), del(clear(X)), % list of conditions del(on(X, Y)), add(clear(Y)), % to be added and add(holding(X))]) % deleted CSC 8520 Spring Paula Matuszek
5
CSC 8520 Spring 2013. Paula Matuszek
plan plan takes a current state, a goal state, a list of states which have already been reached (Been_list), and a list of moves which have already been carried out. It then checks to see if the current state = goal state. If so, print out list of moves. finds an applicable move does the adds and deletes checks to be sure we haven’t already been there adds the current state to the list of states and the current move to the list of moves recurs. CSC 8520 Spring Paula Matuszek
6
CSC 8520 Spring 2013. Paula Matuszek
Running it go takes an initial state and a goal state it invokes plan with current state = initial state goal state = goal state Been_list = initial state Moves list empty. test is just there to give a way to test it, using the blocks world. CSC 8520 Spring Paula Matuszek 6
7
CSC 8520 Spring 2013. Paula Matuszek
Spare tire problem Problem: you have a flat. Develop a plan to fix it. Initial condition is that the flat is on the axle and the spare is in the trunk. Goal condition is that the flat is in the trunk and the spare is on the axle. Some possible actions include removing something from something, installing something in something. Some possible conditions include at(a,b) and clear(axle) CSC 8520 Spring Paula Matuszek
8
CSC 8520 Spring 2013. Paula Matuszek
Lab exercise 2. Develop the appropriate initial state, goal state and move definitions for the Spare Tire Problem. Add to planner.pl your moves and a new predicate test2 which solves this problem. CSC 8520 Spring Paula Matuszek
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.