;;;;LOL Wizard game start
       #|
       $ rlwrap ecl -load lisp.house
       > (look)
       I am in a living-room
       Exits to: (LADDER DOOR)
       NIL
       > (traverse 'ladder)
       I am in an attic
       Exits to: (LADDER)
       NIL
       > (traverse 'ladder)
       I am in a living-room
       Exits to: (LADDER DOOR)
       NIL
       > (traverse 'door)
       I am in a garden
       Exits to: (DOOR)
       NIL
       > *room*
       
       #1=(CURRENT GARDEN #2=(DOOR LIVING-ROOM (LADDER ATTIC #2#) #1#))
       |#
       
       #| 
       I was inspired by Land of Lisp's use of #'ASH
       which does bitshifting in the number-guess-game
       to be cute with travelling between rooms in the
       start of making my wizard game using circles and #'rplaca.
       |#
       
       (setq *print-circle* t)
       
       #|
       I'm also social media detoxing right now.
       
       Can someone help havoc dig in?
       
       Also ldbeth and mhcat I want to see your historical
       wizard games if you have them (and everyone's)
       
       While I'm here nm03 I would like to hear your synth
       |#
       
       (setq *room* '(current living-room 
                      (ladder attic) 
                      (door garden)))
       
       #| 
       listen, I grew this organically.
       
       I think it makes sense that travelling back and
       forth through a door ends up in the same place
       even though you are only going forwards (in the
       singly linked list using cdr)
       
       Here I manually circle-ise each of two connected
       rooms.
       
       Since I wanted to go through a door, but arrive
       in a room, the list got a bit complicated.
       |#
       
       (setf (cdr (cdadr (cdr *room*))) (list *room*)
            (cdr (cdaddr (cdr *room*))) (list *room*))
       
       
       (defvar *vowels* '(#\a #\e #\i #\o #\u))
       
       (defun look () "
       (look)
       I am in an attic
       Exits to: (LADDER)
       "
        (let ((string (format nil "~(~a~)" (cadr *room*)))
              (exits (mapcar 'car (cddr *room*))))
         (format t "I am in a~@[n~1*~] ~a~%"
                (find (char string 0) *vowels*)
                string)
         #| "Seedy underbelly of lisp" ha ha ha |#
         (format t "Exits to: ~a" exits)))
       
       (defun traverse (edge) "
       (traverse 'door)
       "
        (let ((destination (assoc edge (cddr *room*))))
         (cond (destination (rplaca *room* edge)
                            (setq *room* destination)
                            (rplaca *room* 'current))
               ((null destination) (format t "~a not found~%" edge))
               (t (error "Mystery error"))))
        (look))
       
       #|
       Since I had just read five chapters introducing
       bits of lisp culture and the whole thing with
       parens syntax and conses, the moment the wizard
       game concept was mentioned I went for broke so
       I might have diverged from the book.
       |#
       
       #|
       someone got my experimental search to break before.
       so it's off right now. I wrote a new one, but
       didn't roll it out yet.
       |#