Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Building a Text Game Engine > Describing the Paths

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

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint