Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

731 rinda
22KB

  1. (import comparse)
  2. (import srfi-1)
  3. (import srfi-14)
  4. (import (chicken io))
  5. (import srfi-13)
  6. (import matchable)
  7. (import fmt)
  8. (import fmt-color)
  9. (import fmt-unicode)
  10. (import ansi-escape-sequences)
  11. (import (chicken file))
  12. (import breadline)
  13. (define (lift fn parser)
  14. (bind parser (compose result fn)))
  15. (define (is-not x)
  16. (satisfies (lambda (y)
  17. (not (eqv? x y)))))
  18. (define (curry fn a)
  19. (lambda (b)
  20. (fn a b)))
  21. (define (applied fn)
  22. (curry apply fn))
  23. (define-syntax thunk
  24. (syntax-rules ()
  25. ((_ exp ...)
  26. (lambda () exp ...))))
  27. (define parse-whitespace
  28. (one-or-more (is #\space)))
  29. (define skip-whitespace
  30. (skip (zero-or-more (is #\space))))
  31. (define +letter-char-set+
  32. (string->char-set "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVwXYZ"))
  33. (define +symbol-char-set+
  34. (char-set-union +letter-char-set+ (string->char-set "-0123456789")))
  35. (define parse-symbol
  36. (lift (compose string->symbol string-downcase list->string (applied append))
  37. (sequence (lift list (in +letter-char-set+)) (zero-or-more (in +symbol-char-set+)))))
  38. (define parse-number
  39. (lift (compose string->number list->string) (one-or-more (in char-set:digit))))
  40. (define parse-string
  41. (lift list->string (enclosed-by (is #\") (one-or-more (is-not #\")) (is #\"))))
  42. (define (followed-by-consuming parser separator)
  43. (sequence* ((value parser) (_ separator))
  44. (result value)))
  45. (define (separated-by separator parser)
  46. (one-or-more (any-of (followed-by-consuming parser separator) parser)))
  47. (define parse-symbol-or-number-or-string
  48. (any-of parse-number parse-symbol parse-string))
  49. (define (completely-parse parser)
  50. (followed-by parser end-of-input))
  51. (define parse-statement
  52. (all-of skip-whitespace (separated-by parse-whitespace parse-symbol-or-number-or-string)))
  53. (define (just fn)
  54. (lambda args
  55. (fn)))
  56. (define (perhaps fn arg)
  57. (if arg
  58. (fn arg)
  59. arg))
  60. (define display-newline
  61. (compose (just newline) display))
  62. (define (display-lines ln)
  63. (perhaps (curry map display-newline) ln))
  64. (define (parse-input)
  65. (parse (completely-parse parse-statement) (read-line)))
  66. (define parse-formatter
  67. (recursive-parser (one-or-more (any-of (followed-by-consuming (char-seq "<b>") (lift fmt-bold parser))
  68. (is-not #\<)))))
  69. (define (type-of elem)
  70. (cond ((pair? elem) 'pair)
  71. ((symbol? elem) 'symbol)
  72. ((number? elem) 'number)
  73. ((char? elem) 'char)
  74. ((string? elem) 'string)
  75. ((boolean? elem) 'boolean)))
  76. (define (show str)
  77. (fmt #t (dsp (wrap-lines str))))
  78. (define (prompt str)
  79. (newline)
  80. (let ((result (readline str)))
  81. (if (equal? "" result)
  82. (prompt str)
  83. (begin
  84. (add-history! result)
  85. result))))
  86. (define (prompt-yn str)
  87. (newline)
  88. (let ((result (string-downcase (readline str))))
  89. (cond ((equal? "yes" result) #t)
  90. ((equal? "no" result) #f)
  91. (else (begin
  92. (newline)
  93. (display "Please answer yes or no.")
  94. (prompt-yn str))))))
  95. (define (prompt-default str default)
  96. (map stuff-char (string->list default))
  97. (let loop ()
  98. (let ((result (readline str)))
  99. (if (equal? "" result)
  100. (loop)
  101. result))))
  102. (define +articles-prepositions+
  103. '(a an the into on to at as))
  104. (define (adventure-prompt)
  105. (let ((result (parse (completely-parse parse-statement) (prompt "> "))))
  106. (if result
  107. (let ((grug-result (filter (compose not (cut member <> +articles-prepositions+)) result)))
  108. (if (not (null? grug-result))
  109. grug-result
  110. (begin (display "I didn't quite understand that.")
  111. (adventure-prompt))))
  112. (begin (display "I didn't quite understand that.")
  113. (adventure-prompt)))))
  114. (define (compose-symbols . ln)
  115. (string->symbol
  116. (let loop ((ln ln))
  117. (case (length ln)
  118. ((0) '())
  119. ((1) (symbol->string (car ln)))
  120. (else (string-append (symbol->string (car ln)) "-" (loop (cdr ln))))))))
  121. (define *database* '())
  122. (define (database-set name key value)
  123. (set! *database* (let loop ((kv *database*))
  124. (if (null? kv)
  125. (list (cons name (list (cons key value))))
  126. (if (equal? name (caar kv))
  127. (cons (cons name (let loop ((kv (cdar kv)))
  128. (if (null? kv)
  129. (list (cons key value))
  130. (if (equal? key (caar kv))
  131. (cons (cons key value) (cdr kv))
  132. (cons (car kv) (loop (cdr kv))))))) (cdr kv))
  133. (cons (car kv) (loop (cdr kv))))))))
  134. (define (database-get name key default)
  135. (let loop ((kv *database*))
  136. (if (null? kv)
  137. default
  138. (if (equal? name (caar kv))
  139. (let loop ((kv (cdar kv)))
  140. (if (null? kv)
  141. default
  142. (if (equal? key (caar kv))
  143. (cdar kv)
  144. (loop (cdr kv)))))
  145. (loop (cdr kv))))))
  146. (define (database-save filename)
  147. (with-output-to-file filename (thunk (write *database*))))
  148. (define (database-load filename)
  149. (with-input-from-file filename (thunk (set! *database* (car (read-list))))))
  150. (define (database-remove name)
  151. (let loop ((kv *database*))
  152. (if (null? kv)
  153. '()
  154. (if (equal? name (caar kv))
  155. (cdr kv)
  156. (cons (car kv) (loop (cdr kv)))))))
  157. (define (get-all-objects)
  158. (map car *database*))
  159. (define (object-exists? object)
  160. (member object (get-all-objects)))
  161. (define (has-property? object property)
  162. (database-get object property #f))
  163. (define (toggle-flag object flag)
  164. (if (has-property? object flag)
  165. (database-set object flag #f)
  166. (database-set object flag #t)))
  167. (define (get-location object)
  168. (database-get object 'location #f))
  169. (define (set-name object name)
  170. (database-set object 'name name))
  171. (define (set-description object description)
  172. (database-set object 'description description))
  173. (define (get-name object)
  174. (database-get object 'name (symbol->string object)))
  175. (define (get-description object)
  176. (database-get object 'description "You see the swirling void of creation."))
  177. (define (get-container object)
  178. (database-get object 'container #f))
  179. (define (get-contents object)
  180. (database-get object 'contents '()))
  181. (define (set-destination object destination)
  182. (database-set object 'destination destination))
  183. (define (get-destination object)
  184. (database-get object 'destination #f))
  185. (define (set-enter-message object msg)
  186. (database-set object 'enter-message msg))
  187. (define (get-enter-message object)
  188. (database-get object 'enter-message #f))
  189. (define (get-aliases object)
  190. (database-get object 'aliases '()))
  191. (define (set-aliases object alias-list)
  192. (database-set object 'aliases alias-list))
  193. (define (add-alias object alias)
  194. (let ((aliases (get-aliases object)))
  195. (if (not (member alias aliases))
  196. (set-aliases object (cons alias aliases)))))
  197. (define (remove-alias object alias)
  198. (let ((aliases (get-aliases object)))
  199. (if (member alias aliases)
  200. (set-aliases object (remove (curry eq? alias) aliases)))))
  201. (define (set-hidden object value)
  202. (database-set object 'hidden value))
  203. (define (get-hidden object)
  204. (database-get object 'hidden #f))
  205. (define (set-fixed object value)
  206. (database-set object 'fixed value))
  207. (define (get-fixed object value)
  208. (database-get object 'hidden #f))
  209. (define (get-put-message object)
  210. (database-get object 'put-message "You put the ~a into the ~a."))
  211. ;; Is development mode enabled?
  212. (define (devmode-enabled?)
  213. (has-property? 'you 'devmode))
  214. (define (toggle-devmode)
  215. (toggle-flag 'you 'devmode))
  216. ;; Is an object fixed in place (e.g. cannot be picked up?)
  217. (define (fixed? object)
  218. (has-property? object 'fixed))
  219. (define (toggle-fixed object)
  220. (toggle-flag object 'fixed))
  221. ;; Match a tag against a list of objects, checking for its tag and its aliases.
  222. (define (match-object tag objects)
  223. (let loop ((objects objects))
  224. (if (null? objects)
  225. #f
  226. (let ((taglist (cons (car objects) (get-aliases (car objects)))))
  227. (if (member tag taglist)
  228. (car objects)
  229. (loop (cdr objects)))))))
  230. (define (create-object tag name description)
  231. (set-name tag name)
  232. (set-description tag description))
  233. (define (move-object object container)
  234. (let ((prev-container (get-container object)))
  235. (database-set object 'container container)
  236. (let ((contents (get-contents container)))
  237. (if (not (member object contents))
  238. (begin
  239. (database-set container 'contents (cons object contents))
  240. (database-set prev-container 'contents (remove (curry eq? object) (get-contents prev-container))))))))
  241. ;; Determine the objects visible to a source object, zork-style
  242. (define (visible-objects source)
  243. (let ((result (get-container source)))
  244. (if (and result (object-exists? result))
  245. (cons (get-container source) (get-contents (get-container source)))
  246. (error "Tried to determine visible objects for object without a container."))))
  247. (define (any-or fn ln thunk)
  248. (let loop ((ln ln))
  249. (if (null? ln)
  250. (thunk)
  251. (let ((result (fn (car ln))))
  252. (if result
  253. result
  254. (loop (cdr ln)))))))
  255. (define (lisp body environments exit)
  256. (define (eval body)
  257. (lisp body environments exit))
  258. (define (reference symbol)
  259. (cdr (any-or (curry assoc symbol) environments (exit (string-append "Undefined reference: " (symbol->string symbol))))))
  260. ; (define (apply function function-args)
  261. ; (if
  262. (if (atom? body)
  263. (if (symbol? body)
  264. (reference body)
  265. body)
  266. (let ((function-name (car body))
  267. (function-args (cdr body)))
  268. (if (symbol? function-name)
  269. (case function-name
  270. ((test) (show "test function called"))
  271. ((if) (match function-args
  272. ((e x y) (if (eval e)
  273. (eval x)
  274. (eval y)))
  275. (_ (exit "malformed if expression"))))
  276. ((quote) (match function-args
  277. ((v) v)
  278. (_ (exit "malformed quote expression"))))
  279. ((cons) (match function-args
  280. ((a b) (cons (eval a) (eval b)))
  281. (_ (exit "malformed cons expression"))))
  282. ((car) (match function-args
  283. ((a) (let ((ae (eval a)))
  284. (if (atom? ae)
  285. (exit "tried to take car of atom")
  286. (car (eval a)))))
  287. (_ (exit "malformed car expression"))))
  288. ((cdr) (match function-args
  289. ((a) (cdr (eval a)))))
  290. ((atom) (match function-args
  291. ((a) (atom? (eval a)))
  292. (_ (exit "malformed atom expression"))))
  293. ((eq) (match function-args
  294. ((a b) (equal? (eval a) (eval b)))
  295. (_ (exit "malformed eval expression"))))
  296. ; ((set) (match function-args
  297. ; ((a b) (if (
  298. ((lambda) (match function-args
  299. ((args exp . exps)
  300. (if (and (list? args) (every symbol? args))
  301. (cons args (cons exp exps))
  302. (exit "malformed lambda expression")))
  303. (_ (exit "malformed lambda expression"))))
  304. (else (let ((function (reference function-name environments)))
  305. (let ((function-arguments (car function))
  306. (argument-values (cdr body))
  307. (function-body (cddr function)))
  308. (lisp function-body (cons (if (= (length function-arguments) (length argument-values))
  309. (map cons function-arguments (map eval argument-values))
  310. (exit "Wrong number of arguments to function")) environments exit))))))
  311. (exit "attempt to call atom")))))
  312. (define (run-lisp body)
  313. (call/cc (lambda (exit)
  314. (cons #t (lisp body '(()) (compose exit (curry cons #f)))))))
  315. ;; (if (and (list function)
  316. ;; (>= (length function) 2)
  317. ;; (list function-arguments)
  318. ;; (every symbol? (car function)))
  319. (define +script-primitives+
  320. `((if . ,(lambda (condition body1 body2)
  321. (script (if (script condition)
  322. body1
  323. body2))))
  324. (eq . ,(lambda (a b)
  325. (equals? (script a) (script b))))
  326. (and . ,(lambda (a b)
  327. (and (script a) (script b))))
  328. (or . ,(lambda (a b)
  329. (or (script a) (script b))))
  330. (not . ,(lambda (a)
  331. (not (script a))))))
  332. (define (print-room-description room)
  333. (newline)
  334. (display (set-text '(bold) (get-name room)))
  335. (if (devmode-enabled?) (display (set-text '(bold fg-green) (string-append " [" (symbol->string room) "]"))))
  336. (newline)
  337. (display " ")
  338. (fmt #t (dsp (wrap-lines (get-description room))))
  339. (newline)
  340. (display "You see: ")
  341. (map (lambda (n) (if (not (get-hidden n)) (begin (display (get-name n)) (display " ") (if (devmode-enabled?) (begin (display (set-text '(bold fg-green) (string-append "[" (symbol->string n) "] ")))))))) (remove (curry eq? 'you) (get-contents room)))
  342. (newline))
  343. (define (do-command-enter tag)
  344. (let ((object (match-object tag (visible-objects 'you))))
  345. (if (not object)
  346. (show "You cannot go that way.")
  347. (let ((destination (get-destination object)))
  348. (if (not destination)
  349. (show "You cannot enter that.")
  350. (begin
  351. (move-object 'you destination)
  352. (perhaps show (get-enter-message object))
  353. (print-room-description (get-container 'you))))))))
  354. (define (do-command-save)
  355. (let ((save-name (prompt-default "Enter save name: " "kekkonen.sav")))
  356. (if (or (not (file-exists? save-name)) (prompt-yn "That file already exists. Overwrite? "))
  357. (begin
  358. (show "Saving database, please wait...")
  359. (database-save save-name)
  360. (show "Done.")))))
  361. (define (do-command-load)
  362. (let ((save-name (prompt-default "Enter save file name to load: " "kekkonen.sav")))
  363. (if (not (file-exists? save-name))
  364. (show "That file does not exist.")
  365. (begin
  366. (show "Loading database, please wait...")
  367. (database-load save-name)
  368. (show "Done.")))))
  369. (define (do-command-look)
  370. (print-room-description (get-container 'you)))
  371. (define (do-command-examine tag)
  372. (let ((object (match-object tag (visible-objects 'you))))
  373. (if (not object)
  374. (show "You cannot see that here.")
  375. (show (get-description object)))))
  376. (define (do-command-inventory)
  377. (map (compose show get-name) (get-contents 'you)))
  378. (define (do-command-take tag)
  379. (if (not (symbol? tag))
  380. (show "I didn't quite understand that.")
  381. (let ((object (match-object tag (if (devmode-enabled?)
  382. (get-all-objects)
  383. (visible-objects 'you)))))
  384. (if (or (not object) (and (fixed? object) (not (devmode-enabled?))))
  385. (if object
  386. (show "That is fixed in place.")
  387. (show "You cannot see that here."))
  388. (begin
  389. (show (string-append "You get " (get-name object) "."))
  390. (move-object object 'you))))))
  391. (define (do-command-drop tag)
  392. (if (not (symbol? tag))
  393. (show "I didn't quite understand that.")
  394. (let ((object (match-object tag (get-contents 'you))))
  395. (if (not object)
  396. (show "You are not carrying that.")
  397. (begin
  398. (show (string-append "You drop " (get-name object) "."))
  399. (move-object object (get-container 'you)))))))
  400. (define (do-command-put tag destination-tag)
  401. (let ((object (match-object tag (get-contents 'you))))
  402. (if (not object)
  403. (show "You are not carrying that.")
  404. (let ((destination-object (match-object destination-tag (visible-objects 'you))))
  405. (if (not destination-object)
  406. (show "You cannot see that here.")
  407. (move-object object (get-destination destination-object)))))))
  408. (define (do-command-devmode)
  409. (toggle-devmode)
  410. (if (devmode-enabled?)
  411. (show "Development mode enabled.")
  412. (show "Development mode disabled.")))
  413. (define (do-command-create tag name description)
  414. (if (not (and (symbol? tag) (string? name) (string? description)))
  415. (show "I didn't quite understand that.")
  416. (if (object-exists? tag)
  417. (show "That object already exists.")
  418. (begin
  419. (create-object tag name description)
  420. (move-object tag (get-container 'you))))))
  421. (define (do-setter-command tag value type? setter)
  422. (if (not (and (symbol? tag) (type? value)))
  423. (show "I didn't quite understand that.")
  424. (let ((object (match-object tag (visible-objects 'you))))
  425. (if (not object)
  426. (show "You can't see that here.")
  427. (begin
  428. (setter object value)
  429. (show "You set a value."))))))
  430. (define (do-command-rename tag name)
  431. (do-setter-command tag name string? set-name))
  432. (define (do-command-describe tag description)
  433. (do-setter-command tag description string? set-description))
  434. (define (do-command-flag tag flag)
  435. (if (not (and (symbol? tag) (symbol? flag)))
  436. (show "I didn't quite understand that.")
  437. (let ((object (match-object tag (visible-objects 'you))))
  438. (if (not object)
  439. (show "You can't see that here.")
  440. (begin
  441. (case flag
  442. ((fixed) (set-fixed object #t))
  443. ((hidden) (set-hidden object #t))
  444. (else (show "Invalid flag name."))))))))
  445. (define (do-command-unflag tag flag)
  446. (if (not (and (symbol? tag) (symbol? flag)))
  447. (show "I didn't quite understand that.")
  448. (let ((object (match-object tag (visible-objects 'you))))
  449. (if (not object)
  450. (show "You can't see that here.")
  451. (begin
  452. (case flag
  453. ((fixed) (set-fixed object #f))
  454. ((hidden) (set-hidden object #f))
  455. (else (show "Invalid flag name."))))))))
  456. (define (do-command-alias tag alias)
  457. (if (not (and (symbol? tag) (symbol? alias)))
  458. (show "I didn't quite understand that.")
  459. (let ((object (match-object tag (visible-objects 'you))))
  460. (if (not object)
  461. (show "You can't see that here.")
  462. (begin
  463. (add-alias object alias)
  464. (show "You add an alias."))))))
  465. (define (do-command-unalias tag alias)
  466. (if (not (and (symbol? tag) (symbol? alias)))
  467. (show "I didn't quite understand that.")
  468. (let ((object (match-object tag (visible-objects 'you))))
  469. (if (not object)
  470. (show "You can't see that here.")
  471. (begin
  472. (remove-alias object alias)
  473. (show "You remove an alias."))))))
  474. (define (do-command-destroy tag)
  475. (if (not (symbol? tag))
  476. (show "I didn't quite understand that.")
  477. (database-remove tag)))
  478. (define (do-command-aliases tag)
  479. (if (not (symbol? tag))
  480. (show "I didn't quite understand that.")
  481. (let ((object (match-object tag (visible-objects 'you))))
  482. (if (not object)
  483. (show "You can't see that here.")
  484. (begin
  485. (newline)
  486. (map (lambda (x) (display x) (display " ")) (get-aliases object))
  487. (newline))))))
  488. (define (do-command-message tag message-tag message)
  489. (if (not (and (symbol? tag) (symbol? message-tag) (string? message)))
  490. (show "I didn't quite understand that")
  491. (let ((object (match-object tag (visible-objects 'you))))
  492. (if (not object)
  493. (show "You can't see that here.")
  494. (case message-tag
  495. ((enter) (set-enter-message object message))
  496. (else (show "Invalid message name.")))))))
  497. (define +cardinal-sets+
  498. '((north n)
  499. (northeast ne north-east)
  500. (east e)
  501. (southeast se south-east)
  502. (south s)
  503. (southwest sw south-west)
  504. (west w)
  505. (northwest nw north-west)
  506. (up u)
  507. (down d)))
  508. (define +cardinal-opposites+
  509. '((north . south)
  510. (northeast . southwest)
  511. (east . west)
  512. (southeast . northwest)
  513. (south . north)
  514. (southwest . northeast)
  515. (west . east)
  516. (northwest . southeast)
  517. (up . down)
  518. (down . up)))
  519. (define (get-cardinal-set direction)
  520. (find (curry member direction) +cardinal-sets+))
  521. (define (get-cardinal-aliases direction)
  522. (perhaps (curry remove (curry eq? direction)) (get-cardinal-set direction)))
  523. (define (cardinal-direction? direction)
  524. (list? (member direction (flatten +cardinal-sets+))))
  525. (define (get-inverse-direction direction)
  526. (perhaps cdr (assoc direction +cardinal-opposites+)))
  527. (define (get-canonical-cardinal-direction-name direction)
  528. (perhaps car (get-cardinal-set direction)))
  529. (define (do-command-dig direction destination)
  530. (if (not (and (symbol? direction) (symbol? destination)))
  531. (show "I didn't quite understand that.")
  532. (if (not (cardinal-direction? direction))
  533. (show "You must specify a compass rose direction or up and down.")
  534. (let ((canonical-direction (get-canonical-cardinal-direction-name direction)))
  535. (let ((exit-tag (compose-symbols canonical-direction (get-container 'you) destination)))
  536. (if (object-exists? exit-tag)
  537. (show "An exit like that already exists.")
  538. (begin
  539. (move-object exit-tag (get-container 'you))
  540. (set-hidden exit-tag #t)
  541. (set-destination exit-tag destination)
  542. (map (curry add-alias exit-tag) (get-cardinal-set direction))
  543. (show "You create a passage."))))))))
  544. (define (do-command-exit)
  545. (show "Goodbye, see you later...")
  546. (set! *exit-adventure* #t))
  547. (define (alias-transform input)
  548. (match input
  549. (('quit) '(exit))
  550. (('i) '(inventory))
  551. (('inv) '(inventory))
  552. (('look x) `(examine ,x))
  553. (('go x) `(enter ,x))
  554. (('get x) `(take ,x))
  555. ((x) (if (cardinal-direction? x)
  556. `(enter ,x)
  557. input))
  558. (_ input)))
  559. (define (dispatch-command input)
  560. (let ((success #t))
  561. (match input
  562. (('look) (do-command-look))
  563. (('save) (do-command-save))
  564. (('load) (do-command-load))
  565. (('devmode) (do-command-devmode))
  566. (('exit) (do-command-exit))
  567. (('enter x) (do-command-enter x))
  568. (('take x) (do-command-take x))
  569. (('drop x) (do-command-drop x))
  570. (('inventory) (do-command-inventory))
  571. (('examine x) (do-command-examine x))
  572. (('put x y) (do-command-put x y))
  573. (_ (if (devmode-enabled?)
  574. (match input
  575. (('create x y z) (do-command-create x y z))
  576. (('rename x y) (do-command-rename x y))
  577. (('describe x y) (do-command-describe x y))
  578. (('dig x y) (do-command-dig x y))
  579. (('flag x y) (do-command-flag x y))
  580. (('unflag x y) (do-command-unflag x y))
  581. (('alias x y) (do-command-alias x y))
  582. (('unalias x y) (do-command-unalias x y))
  583. (('destroy x) (do-command-destroy x))
  584. (('aliases x) (do-command-aliases x))
  585. (('message x y z) (do-command-message x y z))
  586. (_ (set! success #f)))
  587. (set! success #f))))
  588. success))
  589. (create-object 'garden "A Well-Kept Garden" "A french-style garden with topiary in the shape of various animals. A fountain gurgles happily in the middle. A trail leads off into a forest to the north.")
  590. (create-object 'unicorn "a frolicking unicorn" "A white unicorn, with a long spiral horn.")
  591. (create-object 'forest "A Foreboding Forest" "Tall trees bunch around a winding path.")
  592. (create-object 'trail "a trail" "A winding trail.")
  593. (add-alias 'trail 'winding)
  594. (add-alias 'trail 'north)
  595. (add-alias 'trail 'n)
  596. (set-hidden 'trail #t)
  597. (set-enter-message 'trail "You walk along the winding trail...")
  598. (move-object 'you 'garden)
  599. (move-object 'trail 'garden)
  600. (toggle-fixed 'trail)
  601. (set-destination 'trail 'forest)
  602. (move-object 'unicorn 'garden)
  603. (define *exit-adventure* #f)
  604. (define (adventure)
  605. (let ((success (dispatch-command (alias-transform (adventure-prompt)))))
  606. (if (not success)
  607. (begin
  608. (show "I didn't quite understand that.")
  609. (adventure))
  610. (if *exit-adventure*
  611. (display *database*)
  612. (adventure)))))
  613. (print-room-description (get-container 'you))
  614. (adventure)