You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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