Where oh where do I go?
Posted: Sun May 13, 2012 6:22 pm
So I've posted a question about this topic before, but I figured this is better than trying to get a response from a reply. Anyways, I've tried what someone suggested and now I'm confused on a small thing. So the input is a room in a house and the output is the rooms that are 1 room away from that input room. The only output working correctly is the last. Every other one returns nil. Why?
> (defun choices (loc)
(if (eql loc 'library)
(append '((east upstairs-bedroom)) '((south back-stairs)))
)
(if (eql loc 'dining-room)
(append '((east pantry)) '((west downstairs-bedroom)) '((north living-room))
))
(if (eql loc 'back-stairs)
(append '((north library)) '((south downstairs-bedroom))
))
(if (eql loc 'downstairs-bedroom)
(append '((north back-stairs)) '((east dining-room))
))
(if (eql loc 'upstairs-bedroom)
(append '((south front-stairs)) '((west library))
))
(if (eql loc 'front-stairs)
(append '((north upstairs-bedroom)) '((south living-room))
))
(if (eql loc 'living-room)
(append '((north front-stairs)) '((east kitchen)) '((south dining-room))
))
(if (eql loc 'kitchen)
(append '((west living-room)) '((south pantry))
))
(if (eql loc 'pantry)
(append '((north kitchen)) '((east dining-room))
)))
> (choices 'library)
NIL
> (choices 'kitchen)
NIL
> (choices 'pantry)
((NORTH KITCHEN) (EAST DINING-ROOM))
>
> (defun choices (loc)
(if (eql loc 'library)
(append '((east upstairs-bedroom)) '((south back-stairs)))
)
(if (eql loc 'dining-room)
(append '((east pantry)) '((west downstairs-bedroom)) '((north living-room))
))
(if (eql loc 'back-stairs)
(append '((north library)) '((south downstairs-bedroom))
))
(if (eql loc 'downstairs-bedroom)
(append '((north back-stairs)) '((east dining-room))
))
(if (eql loc 'upstairs-bedroom)
(append '((south front-stairs)) '((west library))
))
(if (eql loc 'front-stairs)
(append '((north upstairs-bedroom)) '((south living-room))
))
(if (eql loc 'living-room)
(append '((north front-stairs)) '((east kitchen)) '((south dining-room))
))
(if (eql loc 'kitchen)
(append '((west living-room)) '((south pantry))
))
(if (eql loc 'pantry)
(append '((north kitchen)) '((east dining-room))
)))
> (choices 'library)
NIL
> (choices 'kitchen)
NIL
> (choices 'pantry)
((NORTH KITCHEN) (EAST DINING-ROOM))
>