University of Washington
Department of Computer Science and Engineering
CSE473–Artificial Intelligence
Winter 1998
Problem Set #2
Assigned January 26, 1997
Due February 6, 1997
State Space Search, and a Truckworld Agent
This problem set is simplicity itself: write a function
which takes a goal as input, generates a solution plan that solves the goal, and executes that plan in the Truckworld. You can define a goal however you want, though there will be some suggestions below. What’s more, we will be operating in a very simple Truckworld environment, consisting of only three locations and only a few objects:
Here is more detail about the world:
Another nice thing about this world is that the objects always appear at prespecified locations and positions:
Solve the problem in several steps:
1. Formulating the problem
The tricky part of the first step is to decide how to represent the problem (state, operators, goals). It is probably best to begin by defining a goal. You need not use the following representation exactly, but your solution must solve all of the following goals:
(defvar *goal-1* '((GLASS A) (GLASS UNBROKEN)))
(defvar *goal-2* '((GARBAGE RECYCLED)))
(defvar *goal-3* '((GLASS BROKEN)))
(defvar *goal-4* '((ROCK RECYCLED)))
(defvar *goal-5* '((GLASS RECYCLED)))
(defvar *goal-6* '((GLASS C) (GLASS UNBROKEN)))
(defvar *goal-7* '((ROCK RECYCLED) (GLASS RECYCLED)))
(defvar *goal-8* '((GARBAGE B) (GLASS B) (GLASS UNBROKEN)))
(defvar *goal-9* '((ROCK RECYCLED) (GLASS C) (GARBAGE IN-BOX)))
(defvar *goal-10* '((ROCK RECYCLED) (GLASS A)
(GLASS UNBROKEN) (FUEL FULL)))
(defvar *goal-11* '((ROCK RECYCLED) (GLASS C) (GLASS UNBROKEN)
(GARBAGE IN-BOX) (FUEL FULL)))
Another big part of an effective solution will be to limit how long plans get. As you discovered in Problem Sets 0 and 1, even a simple pickup action in Truckworld consists of several primitives; more complex actions like refueling the truck consist of many primitives. It is probably infeasible to generate plans in a space where the operators are Truckworld primitives, as the plans will be too long and thus will take too long to generate. You should therefore use the concept of "macro-operators" from Problem Set 1: your search operators will be macrops instead of primitives.
In the PS2 directory, you will find macrops that correspond to many of the search operators you will need. For PS2, one extra feature has been added to the macrop expansion code which lets you use the name of an object in place of its location, i.e.,
(pick-up !glass)
You will also have to come up with a heuristic ranking function for the search. (Hint: concentrate on detecting repeated states and eliminating "nonsense" move sequences, e.g. picking up an object then immediately putting it down.)
2. Generating the solution
Use two methods to perform the search: iterative deepening search, and heuristic search based on your own ranking function. To do the former, you will have to extend the algorithm in
search.lsp to do iterative deepening search.
3. Executing the solution
Your search will supply you with a list of macro-operators that will move the world into a goal state. Now all that is left is to execute that solution in the Truckworld. You can use the truckworld interface and macrop code from Problem Set 1, including the following functions:
EXTRA CREDIT
Careful, this is hard!
Suppose the agent knew the location of objects, but not their exact positions. It could then generate an abstract plan, but could not plan down to the level of primitives.
But the agent could compensate for this lack of information by using its sensors to find out where an object was at plan-execution time.
The behaviors we developed in Problem Set 1 implement this sort of abstract operator. For example, the pickup-recyclable behavior can be viewed as an abstract search operator with a precondition that there is a piece of recyclable material somewhere at the truck’s current location, and a postcondition that the recyclable object is no longer at that location and is being held by the truck.
Rewrite your search problem so that