Describing the Paths

Now that we have basic descriptions of each location, we need descriptions of paths to other locations as well. We’ll create a second variable, *edges*, that contains the paths that players can take to move between places on our map. (We use the term edges because that’s the proper math term for the lines connecting nodes in a graph.)

(defparameter *edges* '((living-room (garden west door)
                                     (attic upstairs ladder))
                        (garden (living-room east door))
                        (attic (living-room downstairs ladder))))

Using this structure, we create the describe-path function, which builds a textual description of a given edge using our symbols system.

(defun describe-path (edge)
  `(there is a ,(caddr edge) going ,(cadr edge) from here.))

This describe-path ...

Get Land of Lisp now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.