CIS 479/579 Project 1
Summer 2008
Your first programming assignment will give you an chance
to explore symbolic computation as you write a series of Lisp
functions to help Robbie the robot move around his house. A
map of his house appears below.
N
|
Library----------Upstairs-Bedroom W-+-E
| | |
| | S
| Front-Stairs
Back-Stairs |
| |
| |
| Living-Room-----------Kitchen
| | |
| | |
Downstairs-Bedroom-----Dining-Room------------Pantry
This may be represented by a Lisp association list having one entry
for each room which looks like the following:
(LIVING-ROOM (NORTH FRONT-STAIRS)
(SOUTH DINING-ROOM)
(EAST KITCHEN))
The entire map can be found by clicking this link robbie.txt.
Download a copy of this and then write the Lisp functions described
below:
1. A function CHOICES which takes the name of the room and
returns the table of permissible choices for Robbie's next
destination. For example (CHOICES 'PANTRY) returns the
list ((NORTH KITCHEN) (WEST DINING-ROOM)).
2. The function LOOK that takes two inputs, a direction and a
room, and tells Robbie where he will end up if he moved in
that direction from that room. For example if Robbie were
to (LOOK 'NORTH 'PANTRY) he would get (KITCHEN), (LOOK 'WEST
'PANTRY) gives him (DINING-ROOM), (LOOK 'SOUTH 'PANTRY)
gives NIL. (Hint: Use CHOICES somewhere.)
3. An expression which sets a global variable LOC to hold
Robbie's current position in the PANTRY.
4. A function HOW-MANY-CHOICES that tells how many choices
Robbie has for where he may move given the current value of
the variable LOC. If Robbie ie in the PANTRY the function
should return 2.
5. A predicate function UPSTAIRSP that returns T if its input
is an upstairs locations The UPSTAIRS-BEDROOM and the
LIBRARY are the only rooms which qualify.
6. A predicate function ONSTAIRSP which returns T if its input
is either FRONT-STAIRS or BACK-STAIRS.
7. A function WHERE that requires no inputs and tells Robbie
where he is. If he is in the LIBRARY where should return
(ROBBIE IS UPSTAIRS IN THE LIBRARY), if he is in the KITCHEN
it should return (ROBBIE IS DOWNSTAIRS IN THE KITCHEN), and
if he is on the front stairs it should return (ROBBIE IS ON
THE FRONT-STAIRS). (Hint: Use your predicate functions.)
8. A function MOVE that takes one input, a direction, and moves
Robbie in that direction. MOVE should make use of your LOOK
function. If he can't move in the requested direction, an
appropriate message should be returned. For example, if
Robbie is in the PANTRY (MOVE 'SOUTH) should return (OUCH!
ROBBIE HIT A WALL), while (MOVE 'NORTH) should return
(ROBBIE IS DOWNSTAIRS IN THE KITCHEN).
9. Adapt one of the search functions presented in class to
help Robbie find a path from PANTRY to the KITCHEN that
passes through the LIBRARY.
None of these functions is particularly long, if you keep in
mind that you are working with Common LISP (not Pascal or C++).
You should feel free to write any auxiliary functions that would
make your work easier to do. In fact, it may be the case that,
using one of the functions defined above will make your work go
much more quickly (and help improve the structure of your code as
well). You should use XLISP for this assignment. You will need to
turn in a well commented source listing containing your function
definitions, carefully organized test runs (perhaps using the
Common Lisp DRIBBLE function and adding some annotations to the
file using your favorite word processing program to make your
output easier to follow), and a two page memo discussing the
nature (strengths, weaknesses, general approach, etc.) of your
solution. All work is to be submittted as a single MS Word doc or
PDF file.
Date assigned: 5/07/08
Date due: 5/14/08