You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
;; The front door is not locked.;; The front door is not locked.;; Escaping through the front door.
This issue gets further compounded when we have the full try-to-hide-mark
(defuntry-to-hide-mark ()
(let ((choice (find-choice 'escape)))
(cond (choice
(invoke-choice choice))
(t
(formatt";; Kate cannot hide Mark!~%")
(let ((excuse (find-choice 'excuse)))
(when excuse
(let ((excuse-text (elt*excuses* (random (length*excuses*)))))
(invoke-choice excuse excuse-text))))))))
CL-USER> (call-with-home-choices
(lambda ()
(let ((*mark-safe-p*nil)
(*front-door-locked-p*t)
(*back-door-locked-p*t))
(try-to-hide-mark-old))))
;; The front door is locked.;; The back door is locked.;; Kate cannot hide Mark!;; The front door is locked.;; The back door is locked.;; The front door is locked.;; The back door is locked.;; Mark makes an excuse before leaving:;; "Kate did not divide her program into sections properly!"T
The following is my solution
;; flip the order, where we make sure the name comes first!
(defunfind-choice (name)
(loop for choice in *choices*when (and (eq name (choice-name choice))
(funcall (choice-test-function choice)))
return choice))
;; have to let out the additional effects
(defuntry-to-hide-mark ()
(let ((choice (find-choice 'escape)))
(cond (choice
(invoke-choice choice))
(t
(formatt";; Kate cannot hide Mark!~%")
(let ((excuse (find-choice 'excuse)))
(when excuse
(let ((excuse-text (elt*excuses* (random (length*excuses*)))))
(invoke-choice excuse excuse-text))))))))
;; we pass the name itself, not search for it
(defuninvoke-choice (name &rest arguments)
(apply (choice-effect-function name)
arguments))
with the output as follows
(call-with-home-choices
(lambda ()
(let ((*mark-safe-p*nil)
(*front-door-locked-p*t)
(*back-door-locked-p*t))
(try-to-hide-mark))))
;; The front door is locked.;; The back door is locked.;; Kate cannot hide Mark!;; The front door is locked.;; The back door is locked.;; Mark makes an excuse before leaving:;; "I was borrowing Kate's books on mainframe programming!"T
The text was updated successfully, but these errors were encountered:
In this section, the book has the following code snipits
when we call
we get
This issue gets further compounded when we have the full
try-to-hide-mark
The following is my solution
with the output as follows
The text was updated successfully, but these errors were encountered: