You are previewing Land of Lisp.

Land of Lisp

Cover of Land of Lisp by Conrad Barski M.D. Published by No Starch Press

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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.