Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

739 lines
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 (lisp-eval body)
  257. (cond ((atom? body) body)
  258. ((symbol? body) (reference body))
  259. ((list? body) (let ((ln (map lisp-eval body)))
  260. (apply (car ln) (cdr ln))))
  261. (else (exit "Unknown value type in evaluation."))))
  262. (define (reference symbol)
  263. (cdr (any-or (curry assoc symbol) environments (exit (string-append "Undefined reference: " (symbol->string symbol))))))
  264. (define (bind name value)
  265. (set! environments (cons (let loop ((environment (car environments)))
  266. (if (null? environment)
  267. (list (cons name value))
  268. (if (eq? name (caar environment))
  269. (cons (cons name value) (cdr environment))
  270. (loop (cdr environment)))))
  271. (cdr environments))))
  272. (define (lisp-apply function args)
  273. (cond ((function? function)
  274. (apply function args))
  275. ((list? function)
  276. (let ((function-arguments (car function))
  277. (function-body (cddr function)))
  278. (lisp function-body (cons (if (= (length function-argumentsq) (length argument-values))
  279. (map cons function-arguments args)
  280. (exit "Wrong number of arguments to function")) environments) exit)))
  281. (_ (exit "attempt to call atom")))))
  282. (define lisp-builtins
  283. `((test . ,(lambda (function-args)
  284. (show "test function called")))
  285. (if . ,(lambda (function-args)
  286. (match function-args
  287. ((e x y) (if (lisp-eval e)
  288. (lisp-eval x)
  289. (lisp-eval y)))
  290. (_ (exit "malformed if expression")))))
  291. (quote . ,(lambda (function-args)
  292. (match function-args
  293. ((v) v)
  294. (_ (exit "malformed quote expression")))))
  295. (cons . ,(lambda (function-args)
  296. (match function-args
  297. ((a b) (cons (eval a) (eval b)))
  298. (_ (exit "malformed cons expression")))))
  299. (car . ,(lambda (function-args)
  300. (match function-args
  301. ((a) (let ((ae (eval a)))
  302. (if (atom? ae)
  303. (exit "tried to take car of atom")
  304. (car (eval a)))))
  305. (_ (exit "malformed car expression")))))
  306. (cdr . ,(lambda (function-args)
  307. (match function-args
  308. ((a) (cdr (eval a))))))
  309. (atom . ,(lambda (function-args)
  310. (match function-args
  311. ((a) (atom? (eval a)))
  312. (_ (exit "malformed atom expression")))))
  313. (eq . ,(lambda (function-args)
  314. (match function-args
  315. ((a b) (equal? (eval a) (eval b)))
  316. (_ (exit "malformed eval expression")))))
  317. (set . ,(lambda (function-args)
  318. (match function-args
  319. ((a b) (if (symbol? a)
  320. (bind a b))))))
  321. (lambda . ,(lambda (function-args)
  322. match function-args
  323. ((args exp . exps)
  324. (if (and (list? args) (every symbol? args))
  325. (cons args (cons exp exps))
  326. (exit "malformed lambda expression"))
  327. (_ (exit "malformed lambda expression")))))))
  328. (define (run-lisp body)
  329. (call/cc (lambda (exit)
  330. (cons #t (lisp body (list lisp-builtins) (compose exit (curry cons #f)))))))
  331. (define (print-room-description room)
  332. (newline)
  333. (display (set-text '(bold) (get-name room)))
  334. (if (devmode-enabled?) (display (set-text '(bold fg-green) (string-append " [" (symbol->string room) "]"))))
  335. (newline)
  336. (display " ")
  337. (fmt #t (dsp (wrap-lines (get-description room))))
  338. (newline)
  339. (display "You see: ")
  340. (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)))
  341. (newline))
  342. (define (do-command-enter tag)
  343. (let ((object (match-object tag (visible-objects 'you))))
  344. (if (not object)
  345. (show "You cannot go that way.")
  346. (let ((destination (get-destination object)))
  347. (if (not destination)
  348. (show "You cannot enter that.")
  349. (begin
  350. (move-object 'you destination)
  351. (perhaps show (get-enter-message object))
  352. (print-room-description (get-container 'you))))))))
  353. (define (do-command-save)
  354. (let ((save-name (prompt-default "Enter save name: " "kekkonen.sav")))
  355. (if (or (not (file-exists? save-name)) (prompt-yn "That file already exists. Overwrite? "))
  356. (begin
  357. (show "Saving database, please wait...")
  358. (database-save save-name)
  359. (show "Done.")))))
  360. (define (do-command-load)
  361. (let ((save-name (prompt-default "Enter save file name to load: " "kekkonen.sav")))
  362. (if (not (file-exists? save-name))
  363. (show "That file does not exist.")
  364. (begin
  365. (show "Loading database, please wait...")
  366. (database-load save-name)
  367. (show "Done.")))))
  368. (define (do-command-look)
  369. (print-room-description (get-container 'you)))
  370. (define (do-command-examine tag)
  371. (let ((object (match-object tag (visible-objects 'you))))
  372. (if (not object)
  373. (show "You cannot see that here.")
  374. (show (get-description object)))))
  375. (define (do-command-inventory)
  376. (map (compose show get-name) (get-contents 'you)))
  377. (define (do-command-take tag)
  378. (if (not (symbol? tag))
  379. (show "I didn't quite understand that.")
  380. (let ((object (match-object tag (if (devmode-enabled?)
  381. (get-all-objects)
  382. (visible-objects 'you)))))
  383. (if (or (not object) (and (fixed? object) (not (devmode-enabled?))))
  384. (if object
  385. (show "That is fixed in place.")
  386. (show "You cannot see that here."))
  387. (begin
  388. (show (string-append "You get " (get-name object) "."))
  389. (move-object object 'you))))))
  390. (define (do-command-drop tag)
  391. (if (not (symbol? tag))
  392. (show "I didn't quite understand that.")
  393. (let ((object (match-object tag (get-contents 'you))))
  394. (if (not object)
  395. (show "You are not carrying that.")
  396. (begin
  397. (show (string-append "You drop " (get-name object) "."))
  398. (move-object object (get-container 'you)))))))
  399. (define (do-command-put tag destination-tag)
  400. (let ((object (match-object tag (get-contents 'you))))
  401. (if (not object)
  402. (show "You are not carrying that.")
  403. (let ((destination-object (match-object destination-tag (visible-objects 'you))))
  404. (if (not destination-object)
  405. (show "You cannot see that here.")
  406. (move-object object (get-destination destination-object)))))))
  407. (define (do-command-devmode)
  408. (toggle-devmode)
  409. (if (devmode-enabled?)
  410. (show "Development mode enabled.")
  411. (show "Development mode disabled.")))
  412. (define (do-command-create tag name description)
  413. (if (not (and (symbol? tag) (string? name) (string? description)))
  414. (show "I didn't quite understand that.")
  415. (if (object-exists? tag)
  416. (show "That object already exists.")
  417. (begin
  418. (create-object tag name description)
  419. (move-object tag (get-container 'you))))))
  420. (define (do-setter-command tag value type? setter)
  421. (if (not (and (symbol? tag) (type? value)))
  422. (show "I didn't quite understand that.")
  423. (let ((object (match-object tag (visible-objects 'you))))
  424. (if (not object)
  425. (show "You can't see that here.")
  426. (begin
  427. (setter object value)
  428. (show "You set a value."))))))
  429. (define (do-command-rename tag name)
  430. (do-setter-command tag name string? set-name))
  431. (define (do-command-describe tag description)
  432. (do-setter-command tag description string? set-description))
  433. (define (do-command-flag tag flag)
  434. (if (not (and (symbol? tag) (symbol? flag)))
  435. (show "I didn't quite understand that.")
  436. (let ((object (match-object tag (visible-objects 'you))))
  437. (if (not object)
  438. (show "You can't see that here.")
  439. (begin
  440. (case flag
  441. ((fixed) (set-fixed object #t))
  442. ((hidden) (set-hidden object #t))
  443. (else (show "Invalid flag name."))))))))
  444. (define (do-command-unflag tag flag)
  445. (if (not (and (symbol? tag) (symbol? flag)))
  446. (show "I didn't quite understand that.")
  447. (let ((object (match-object tag (visible-objects 'you))))
  448. (if (not object)
  449. (show "You can't see that here.")
  450. (begin
  451. (case flag
  452. ((fixed) (set-fixed object #f))
  453. ((hidden) (set-hidden object #f))
  454. (else (show "Invalid flag name."))))))))
  455. (define (do-command-alias tag alias)
  456. (if (not (and (symbol? tag) (symbol? alias)))
  457. (show "I didn't quite understand that.")
  458. (let ((object (match-object tag (visible-objects 'you))))
  459. (if (not object)
  460. (show "You can't see that here.")
  461. (begin
  462. (add-alias object alias)
  463. (show "You add an alias."))))))
  464. (define (do-command-unalias tag alias)
  465. (if (not (and (symbol? tag) (symbol? alias)))
  466. (show "I didn't quite understand that.")
  467. (let ((object (match-object tag (visible-objects 'you))))
  468. (if (not object)
  469. (show "You can't see that here.")
  470. (begin
  471. (remove-alias object alias)
  472. (show "You remove an alias."))))))
  473. (define (do-command-destroy tag)
  474. (if (not (symbol? tag))
  475. (show "I didn't quite understand that.")
  476. (database-remove tag)))
  477. (define (do-command-aliases tag)
  478. (if (not (symbol? tag))
  479. (show "I didn't quite understand that.")
  480. (let ((object (match-object tag (visible-objects 'you))))
  481. (if (not object)
  482. (show "You can't see that here.")
  483. (begin
  484. (newline)
  485. (map (lambda (x) (display x) (display " ")) (get-aliases object))
  486. (newline))))))
  487. (define (do-command-message tag message-tag message)
  488. (if (not (and (symbol? tag) (symbol? message-tag) (string? message)))
  489. (show "I didn't quite understand that.")
  490. (let ((object (match-object tag (visible-objects 'you))))
  491. (if (not object)
  492. (show "You can't see that here.")
  493. (case message-tag
  494. ((enter) (set-enter-message object message))
  495. (else (show "Invalid message name.")))))))
  496. (define (do-command-goto tag)
  497. (if (not (symbol? tag))
  498. (show "I didn't quite understand that.")
  499. (begin
  500. (move-object 'you tag)
  501. (print-room-description (get-container 'you)))))
  502. (define +cardinal-sets+
  503. '((north n)
  504. (northeast ne north-east)
  505. (east e)
  506. (southeast se south-east)
  507. (south s)
  508. (southwest sw south-west)
  509. (west w)
  510. (northwest nw north-west)
  511. (up u)
  512. (down d)))
  513. (define +cardinal-opposites+
  514. '((north . south)
  515. (northeast . southwest)
  516. (east . west)
  517. (southeast . northwest)
  518. (south . north)
  519. (southwest . northeast)
  520. (west . east)
  521. (northwest . southeast)
  522. (up . down)
  523. (down . up)))
  524. (define (get-cardinal-set direction)
  525. (find (curry member direction) +cardinal-sets+))
  526. (define (get-cardinal-aliases direction)
  527. (perhaps (curry remove (curry eq? direction)) (get-cardinal-set direction)))
  528. (define (cardinal-direction? direction)
  529. (list? (member direction (flatten +cardinal-sets+))))
  530. (define (get-inverse-direction direction)
  531. (perhaps cdr (assoc direction +cardinal-opposites+)))
  532. (define (get-canonical-cardinal-direction-name direction)
  533. (perhaps car (get-cardinal-set direction)))
  534. (define (do-command-dig direction destination)
  535. (if (not (and (symbol? direction) (symbol? destination)))
  536. (show "I didn't quite understand that.")
  537. (if (not (cardinal-direction? direction))
  538. (show "You must specify a compass rose direction or up and down.")
  539. (let ((canonical-direction (get-canonical-cardinal-direction-name direction)))
  540. (let ((exit-tag (compose-symbols canonical-direction (get-container 'you) destination)))
  541. (if (object-exists? exit-tag)
  542. (show "An exit like that already exists.")
  543. (begin
  544. (move-object exit-tag (get-container 'you))
  545. (set-hidden exit-tag #t)
  546. (set-destination exit-tag destination)
  547. (map (curry add-alias exit-tag) (get-cardinal-set direction))
  548. (show "You create a passage."))))))))
  549. (define (do-command-exit)
  550. (show "Goodbye, see you later...")
  551. (set! *exit-adventure* #t))
  552. (define (alias-transform input)
  553. (match input
  554. (('quit) '(exit))
  555. (('i) '(inventory))
  556. (('inv) '(inventory))
  557. (('look x) `(examine ,x))
  558. (('go x) `(enter ,x))
  559. (('get x) `(take ,x))
  560. ((x) (if (cardinal-direction? x)
  561. `(enter ,x)
  562. input))
  563. (_ input)))
  564. (define (dispatch-command input)
  565. (let ((success #t))
  566. (match input
  567. (('look) (do-command-look))
  568. (('save) (do-command-save))
  569. (('load) (do-command-load))
  570. (('devmode) (do-command-devmode))
  571. (('exit) (do-command-exit))
  572. (('enter x) (do-command-enter x))
  573. (('take x) (do-command-take x))
  574. (('drop x) (do-command-drop x))
  575. (('inventory) (do-command-inventory))
  576. (('examine x) (do-command-examine x))
  577. (('put x y) (do-command-put x y))
  578. (_ (if (devmode-enabled?)
  579. (match input
  580. (('create x y z) (do-command-create x y z))
  581. (('rename x y) (do-command-rename x y))
  582. (('describe x y) (do-command-describe x y))
  583. (('dig x y) (do-command-dig x y))
  584. (('flag x y) (do-command-flag x y))
  585. (('unflag x y) (do-command-unflag x y))
  586. (('alias x y) (do-command-alias x y))
  587. (('unalias x y) (do-command-unalias x y))
  588. (('destroy x) (do-command-destroy x))
  589. (('aliases x) (do-command-aliases x))
  590. (('message x y z) (do-command-message x y z))
  591. (('goto x) (do-command-goto x))
  592. (_ (set! success #f)))
  593. (set! success #f))))
  594. success))
  595. (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.")
  596. (create-object 'unicorn "a frolicking unicorn" "A white unicorn, with a long spiral horn.")
  597. (create-object 'forest "A Foreboding Forest" "Tall trees bunch around a winding path.")
  598. (create-object 'trail "a trail" "A winding trail.")
  599. (add-alias 'trail 'winding)
  600. (add-alias 'trail 'north)
  601. (add-alias 'trail 'n)
  602. (set-hidden 'trail #t)
  603. (set-enter-message 'trail "You walk along the winding trail...")
  604. (move-object 'you 'garden)
  605. (move-object 'trail 'garden)
  606. (toggle-fixed 'trail)
  607. (set-destination 'trail 'forest)
  608. (move-object 'unicorn 'garden)
  609. (define *exit-adventure* #f)
  610. (define (adventure)
  611. (let ((success (dispatch-command (alias-transform (adventure-prompt)))))
  612. (if (not success)
  613. (begin
  614. (show "I didn't quite understand that.")
  615. (adventure))
  616. (if *exit-adventure*
  617. (display *database*)
  618. (adventure)))))
  619. (print-room-description (get-container 'you))
  620. (adventure)