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

18. Lazy Programming > Dice of Doom, Version 2

Dice of Doom, Version 2

In Chapter 15, we created the first version of our Dice of Doom game. We are now going to modify some of the functions from that version. To proceed, place the code from that chapter into a file named dice_of_doom_v1.lisp so that we can reference it in this new version (or just download that file from http://landoflisp.com/).

To use our previous Dice of Doom and our new lazy list library, run the following in the REPL:

> (load "dice_of_doom_v1.lisp")
> (load "lazy.lisp")

Next, we’re going to increase the size of our board to a more roomy 4-by-4:

> (defparameter *board-size* 4)
> (defparameter *board-hexnum* (* *board-size* *board-size*))

To allow the game to run at a reasonable speed at this larger size, we’ll make the list of moves at each branch of our game tree a lazy list, instead of just a regular list. By simply converting this one structure in our game from a regular list to a lazy list, the entire game tree will become lazy as a result. To accomplish this, we now need to redefine some of the functions from the first version of our game to use our new lazy list functions.


  

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