1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4 ;;; This file is part of Mudsync.
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;; General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
21 (use-modules (mudsync)
32 ;;; Utilities, useful or otherwise
33 ;;; ==============================
35 (set! *random-state* (random-state-from-platform))
37 (define (random-choice lst)
38 (list-ref lst (random (length lst))))
40 ;; list of lists, lol.
41 (define-syntax-rule (lol (list-contents ...) ...)
42 (list (list list-contents ...) ...))
45 ;;; Some simple object types.
46 ;;; =========================
48 (define-class <readable> (<gameobj>)
49 (read-text #:init-value "All it says is: \"Blah blah blah.\""
50 #:init-keyword #:read-text)
52 #:allocation #:each-subclass
53 #:init-thunk (build-commands
54 ("read" ((direct-command cmd-read)))))
55 (actions #:allocation #:each-subclass
56 #:init-thunk (build-actions
57 (cmd-read readable-cmd-read))))
59 (define (readable-cmd-read actor message . _)
60 (<- (message-from message) 'tell
61 #:text (slot-ref actor 'read-text)))
64 ;; This one allows you to take from items that are proxied by it
65 (define-actor <proxy-items> (<gameobj>)
66 ((cmd-take-from take-from-proxy))
67 (proxy-items #:init-keyword #:proxy-items))
69 (define* (take-from-proxy gameobj message
70 #:key direct-obj indir-obj preposition
71 (player (message-from message)))
76 (define obj-id (dyn-ref gameobj obj-sym))
78 (mbody-val (<-wait obj-id 'goes-by)))
79 (when (ci-member direct-obj goes-by)
80 (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
82 (slot-ref gameobj 'proxy-items))
85 #:text `("You don't see any such " ,direct-obj " to take "
86 ,preposition " " ,(slot-ref gameobj 'name) ".")))))
93 (define (npc-chat-randomly actor message . _)
95 (random-choice (slot-ref actor 'catchphrases)))
97 ((slot-ref actor 'chat-format) actor catchphrase))
98 (<- (message-from message) 'tell
101 (define hotel-owner-grumps
102 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
103 "Don't mind the mess. I built this place on a dare, you
105 "(*tearfully*) Here, take this parenthesis. May it serve
107 "I gotta get back to the goblin farm soon..."
108 "Oh, but I was going to make a mansion... a great,
109 beautiful mansion! Full of ghosts! Now all I have is this cruddy
110 mo... hotel. Oh... If only I had more time!"
111 "I told them to paint more of the walls purple.
112 Why didn't they listen?"
113 "Listen to that overhead muzak. Whoever made that doesn't
114 know how to compose very well! Have you heard of the bands 'fmt'
115 or 'skribe'? Now *that's* composition!"))
117 (define-class <chatty-npc> (<gameobj>)
118 (catchphrases #:init-value '("Blarga blarga blarga!")
119 #:init-keyword #:catchphrases)
120 (chat-format #:init-value (lambda (npc catchphrase)
121 `(,(slot-ref npc 'name) " says: \""
123 #:init-keyword #:chat-format)
125 #:allocation #:each-subclass
126 #:init-thunk (build-commands
127 (("chat" "talk") ((direct-command cmd-chat)))))
128 (actions #:allocation #:each-subclass
131 (cmd-chat npc-chat-randomly))))
133 (define-class <sign-in-form> (<gameobj>)
135 #:allocation #:each-subclass
136 #:init-thunk (build-commands
137 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
139 (actions #:allocation #:each-subclass
140 #:init-thunk (build-actions
141 (cmd-sign-form sign-cmd-sign-in))))
145 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
147 (define forbidden-words
148 (append article preposition
149 '("and" "or" "but" "admin")))
151 (define (valid-name? name)
152 (and (irregex-match name-sre name)
153 (not (member name forbidden-words))))
155 (define* (sign-cmd-sign-in actor message
156 #:key direct-obj indir-obj preposition)
158 (mbody-val (<-wait (message-from message) 'get-name)))
159 (define name indir-obj)
160 (if (valid-name? indir-obj)
162 (<-wait (message-from message) 'set-name! name)
163 (<- (slot-ref actor 'loc) 'tell-room
164 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
165 old-name old-name name)))
166 (<- (message-from message) 'tell
167 #:text "Sorry, that's not a valid name.
168 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
172 (define-class <summoning-bell> (<gameobj>)
173 (summons #:init-keyword #:summons)
176 #:allocation #:each-subclass
177 #:init-thunk (build-commands
178 ("ring" ((direct-command cmd-ring)))))
179 (actions #:allocation #:each-subclass
180 #:init-thunk (build-actions
181 (cmd-ring summoning-bell-cmd-ring))))
183 (define* (summoning-bell-cmd-ring bell message . _)
184 ;; Call back to actor who invoked this message handler
185 ;; and find out their name. We'll call *their* get-name message
186 ;; handler... meanwhile, this procedure suspends until we get
189 (mbody-val (<-wait (message-from message) 'get-name)))
191 ;; Now we'll invoke the "tell" message handler on the player
192 ;; who rang us, displaying this text on their screen.
193 ;; This one just uses <- instead of <-wait, since we don't
194 ;; care when it's delivered; we're not following up on it.
195 (<- (message-from message) 'tell
196 #:text "*ring ring!* You ring the bell!\n")
197 ;; We also want everyone else in the room to "hear" the bell,
198 ;; but they get a different message since they aren't the ones
199 ;; ringing it. Notice here's where we make use of the invoker's
200 ;; name as extracted and assigned to the who-rang variable.
201 ;; Notice how we send this message to our "location", which
202 ;; forwards it to the rest of the occupants in the room.
203 (<- (gameobj-loc bell) 'tell-room
205 (format #f "*ring ring!* ~a rings the bell!\n"
207 #:exclude (message-from message))
208 ;; Now we perform the primary task of the bell, which is to summon
209 ;; the "clerk" character to the room. (This is configurable,
210 ;; so we dynamically look up their address.)
211 (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
212 #:who-summoned (message-from message)))
215 (define prefect-quotes
216 '("I'm a frood who really knows where my towel is!"
217 "On no account allow a Vogon to read poetry at you."
218 "Time is an illusion, lunchtime doubly so!"
219 "How can you have money if none of you produces anything?"
220 "On no account allow Arthur to request tea on this ship."))
222 (define-class <cabinet-item> (<gameobj>)
223 (take-me? #:init-value
226 `("Hm, well... the cabinet is locked and the properitor "
227 "is right over there.")))))
235 '((p "You're in some sort of hotel lobby. You see a large sign hanging "
236 "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
237 "that says \"'ring bell' for service\". Terrible music plays from a speaker "
238 "somewhere overhead. "
239 "The room is lined with various curio cabinets, filled with all sorts "
240 "of kitschy junk. It looks like whoever decorated this place had great "
241 "ambitions, but actually assembled it all in a hurry and used whatever "
242 "kind of objects they found lying around.")
243 (p "There's a door to the north leading to some kind of hallway."))
247 #:to 'grand-hallway)))
251 #:name "a frumpy fellow"
253 '((p " Whoever this is, they looks totally exhausted. They're
254 collapsed into the only comfortable looking chair in the room and you
255 don't get the sense that they're likely to move any time soon.
256 You notice they're wearing a sticker badly adhesed to their clothing
257 which says \"Hotel Proprietor\", but they look so disorganized that you
258 think that can't possibly be true... can it?
259 Despite their exhaustion, you sense they'd be happy to chat with you,
260 though the conversation may be a bit one sided."))
261 #:goes-by '("frumpy fellow" "fellow"
262 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
263 "hotel proprietor" "proprietor")
264 #:catchphrases hotel-owner-grumps)
268 #:name "the Hotel Bricabrac sign"
269 #:desc " It strikes you that there's something funny going on with this sign.
270 Sure enough, if you look at it hard enough, you can tell that someone
271 hastily painted over an existing sign and changed the \"M\" to an \"H\".
273 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
277 "hotel bricabrac sign"
281 <summoning-bell> 'lobby
282 #:name "a shiny brass bell"
283 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
284 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
285 \"ring me for service\". You probably could \"ring the bell\" if you
287 #:summons 'break-room:desk-clerk)
290 <sign-in-form> 'lobby
291 #:name "sign-in form"
292 #:goes-by '("sign-in form" "form" "signin form")
293 #:desc '("It looks like you could sign this form and set your name like so: "
294 (i "sign form as <my-name-here>")))
296 ;; Object: curio cabinets
297 ;; TODO: respond to attempts to open the curio cabinet
300 #:proxy-items '(lobby:porcelain-doll
302 lobby:tea-set lobby:mustard-pot
303 lobby:head-of-elvis lobby:circuitboard-of-evlis
304 lobby:teletype-scroll lobby:orange-cat-phone)
305 #:name "a curio cabinet"
306 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
307 "cabinet of curiosities")
309 (format #f " The curio cabinet is full of all sorts of oddities!
310 Something catches your eye!
311 Ooh, ~a!" (random-choice
312 '("a creepy porcelain doll"
313 "assorted 1950s robots"
314 "an exquisite tea set"
315 "an antique mustard pot"
316 "the pickled head of Elvis"
317 "the pickled circuitboard of EVLIS"
318 "a scroll of teletype paper holding the software Four Freedoms"
319 "a telephone shaped like an orange cartoon cat")))))
321 ('lobby:porcelain-doll
322 <cabinet-item> 'lobby
324 #:name "a creepy porcelain doll"
325 #:desc "It strikes you that while the doll is technically well crafted,
326 it's also the stuff of nightmares."
327 #:goes-by '("porcelain doll" "doll"))
329 <cabinet-item> 'lobby
331 #:name "a set of 1950s robots"
332 #:desc "There's a whole set of these 1950s style robots.
333 They seem to be stamped out of tin, and have various decorations of levers
334 and buttons and springs. Some of them have wind-up knobs on them."
335 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
337 <cabinet-item> 'lobby
340 #:desc "A complete tea set. Some of the cups are chipped.
341 You can imagine yourself joining a tea party using this set, around a
342 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
343 #:goes-by '("tea set" "tea"))
345 <cabinet-item> 'lobby
347 #:name "cups from the tea set"
348 #:desc "They're chipped."
351 <cabinet-item> 'lobby
353 #:name "a mustard pot"
354 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
355 nice design, and it's an antique, but you can't imagine putting something
356 like this in a museum.")
357 (p "Ha... imagine that... a mustard museum."))
358 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
359 ('lobby:head-of-elvis
360 <cabinet-item> 'lobby
362 #:name "the pickled head of Elvis"
363 #:desc '((p "It's a jar full of some briny-looking liquid and...
364 a free floating head. The head looks an awful lot like Elvis, and
365 definitely not the younger Elvis. The hair even somehow maintains
366 that signature swoop while suspended in liquid. But of course it's
368 (p "Oh, wait, it has a label at the bottom which says:
369 \"This is really the head of Elvis\". Well... maybe don't believe
370 everything you read."))
371 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
372 "elvis" "Elvis" "head" "pickled head"))
373 ('lobby:circuitboard-of-evlis
374 <cabinet-item> 'lobby
376 #:name "the pickled circuitboard of Evlis"
377 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
378 This is quite the find, and you bet just about anyone interested in
379 preserving computer history would love to get their hands on this.")
380 (p "Unfortunately, whatever moron did acquire this has
381 no idea what it means to preserve computers, so here it is floating
382 in some kind of briny liquid. It appears to be heavily corroded.
384 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
385 "pickled circuitboard of EVLIS"
386 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
387 ('lobby:teletype-scroll
388 <cabinet-item> 'lobby
390 #:name "a scroll of teletype"
391 #:desc '((p "This is a scroll of teletype paper. It's a bit old
392 and yellowed but the type is very legible. It says:")
395 (p (strong "== The four essential freedoms =="))
396 (p "A program is free software if the program's users have
397 the four essential freedoms: ")
398 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
399 (li "The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.")
400 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
401 (li "The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.")))
402 (p "You get this feeling that ambiguities in the
403 English language surrounding the word 'free' have lead to a lot of terminology debates."))
404 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
405 "teletype paper" "scroll" "four freedoms"
406 "scroll of teletype paper holding the software Four Freedoms"
407 "scroll of teletype paper holding the software four freedoms"))
408 ('lobby:orange-cat-phone
409 <cabinet-item> 'lobby
411 #:name "a telephone shaped like an orange cartoon cat"
412 #:desc "It's made out of a cheap plastic, and it's very orange.
413 It resembles a striped tabby, and it's eyes hold the emotion of
414 a being both sleepy and smarmy.
415 You suspect that someone, somewhere made a ton of cash on items holding
416 this general shape in the 1990s."
417 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
418 "orange cat phone" "orange cat telephone"
419 "cartoon cat phone" "cartoon cat"
420 "cat phone" "cat telephone" "phone" "telephone"))))
427 (define-actor <disc-shield> (<gameobj>)
428 ((cmd-take disc-shield-take)))
430 (define* (disc-shield-take gameobj message
432 (player (message-from message)))
433 (create-gameobj <glowing-disc> (gameobj-gm gameobj)
434 player) ;; set loc to player to put in player's inventory
436 #:text '((p "As you attempt to pull the shield / disk platter
437 from the statue a shining outline appears around it... and a
438 completely separate, glowing copy of the disc materializes into your
440 (<- (gameobj-loc gameobj) 'tell-room
441 #:text `(,(mbody-val (<-wait player 'get-name))
442 " pulls on the shield of the statue, and a glowing "
443 "copy of it materializes into their hands!")
445 (<- (gameobj-loc gameobj) 'tell-room
447 '(p "You hear a voice whisper: "
448 (i "\"Share the software... and you'll be free...\""))))
450 ;;; This is the disc that gets put in the player's inventory
451 (define-actor <glowing-disc> (<gameobj>)
452 ((cmd-drop glowing-disc-drop-cmd))
454 #:allocation #:each-subclass
455 #:init-thunk (build-props
456 '((hd-platter? . #t))))
457 (name #:allocation #:each-subclass
458 #:init-value "a glowing disc")
459 (desc #:allocation #:each-subclass
460 #:init-value "A brightly glowing disc. It's shaped like a hard
461 drive platter, not unlike the one from the statue it came from. It's
462 labeled \"RL02.5\".")
463 (goes-by #:init-value '("glowing disc" "glowing platter"
464 "glowing disc platter" "glowing disk platter"
465 "platter" "disc" "disk" "glowing shield")))
467 (define* (glowing-disc-drop-cmd gameobj message
469 (player (message-from message)))
471 #:text "You drop the glowing disc, and it shatters into a million pieces!")
472 (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
473 #:text `(,(mbody-val (<-wait player 'get-name))
474 " drops a glowing disc, and it shatters into a million pieces!")
476 (gameobj-self-destruct gameobj))
481 (define lobby-map-text
484 .----------.----------. : & : .----------.----------.
485 | computer | |& :YOU ARE: &| smoking | *UNDER* |
486 | room + playroom + : HERE : + parlor | *CONS- |
487 | > | |& : : &| | TRUCTION*|
488 '----------'----------'-++-------++-'-------+--'----------'
494 (define grand-hallway
498 #:name "Grand Hallway"
499 #:desc '((p " A majestic red carpet runs down the center of the room.
500 Busts of serious looking people line the walls, but there's no
501 clear indication that they have any logical relation to this place.")
502 (p "In the center is a large statue of a woman in a warrior's
503 pose, but something is strange about her weapon and shield. You wonder what
505 (p "To the south is the lobby. A door to the east is labeled \"smoking
506 room\", while a door to the west is labeled \"playroom\"."))
516 #:to 'smoking-parlor)))
518 <readable> 'grand-hallway
519 #:name "the hotel map"
520 #:desc '("This appears to be a map of the hotel. "
521 "Like the hotel itself, it seems to be "
523 "You could read it if you want to.")
524 #:read-text `(pre ,lobby-map-text)
525 #:goes-by '("map" "hotel map"))
526 ('grand-hallway:carpet
527 <gameobj> 'grand-hallway
528 #:name "the Grand Hallway carpet"
529 #:desc "It's very red, except in the places where it's very worn."
531 #:goes-by '("red carpet" "carpet"))
532 ('grand-hallway:busts
533 <gameobj> 'grand-hallway
534 #:name "the busts of serious people"
535 #:desc "There are about 6 of them in total. They look distinguished
536 but there's no indication of who they are."
538 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
539 ('grand-hallway:hackthena-statue
540 <proxy-items> 'grand-hallway
541 #:name "the statue of Hackthena"
542 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
543 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
544 all good hacks, and legendary hacker herself.")
545 (p "Hackthena holds the form of a human woman. She wears flowing
546 robes, has a pear of curly bovine-esque horns protruding from the sides of her
547 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
548 But instead of a weapon, she seems to hold some sort of keyboard. And her
549 shield... well it's round like a shield, but something seems off about it.
550 You'd better take a closer look to be sure."))
551 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
552 #:proxy-items '(grand-hallway:keyboard
553 grand-hallway:disc-platter
554 grand-hallway:hackthena-horns))
555 ('grand-hallway:keyboard
556 <gameobj> 'grand-hallway
557 #:name "a Knight Keyboard"
558 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
559 Any space cadet can see that with that kind of layout a hack-and-slayer could
560 thrash out some serious key-chords like there's no tomorrow. You guess
561 Hackthena must be an emacs user."
566 `("Are you kidding? Do you know how hard it is to find "
567 "a Knight Keyboard? There's no way she's going "
568 "to give that up.")))
569 #:goes-by '("knight keyboard" "keyboard"))
570 ('grand-hallway:hackthena-horns
571 <gameobj> 'grand-hallway
572 #:name "Hackthena's horns"
573 #:desc "They're not unlike a Gnu's horns."
578 `("Are you seriously considering desecrating a statue?")))
579 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
580 ('grand-hallway:disc-platter
581 <disc-shield> 'grand-hallway
582 #:name "Hackthena's shield"
583 #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
584 platter! It has \"RL02.5\" written on it. It looks kind of loose."
586 #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
596 #:name "The Playroom"
597 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
598 if this room is intended for children or child-like adults.")
599 (" There are doors to both the east and the west."))
606 #:to 'computer-room)))
611 #:desc " It's a little foam cube with googly eyes on it. So cute!")
612 ('playroom:cuddles-plushie
614 #:name "a Cuddles plushie"
615 #:goes-by '("plushie" "cuddles plushie" "cuddles")
617 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
620 <container> 'playroom
622 #:goes-by '("toy chest" "chest")
623 #:desc (lambda (toy-chest whos-looking)
624 (let ((contents (gameobj-occupants toy-chest)))
625 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
628 ,(if (eq? contents '())
629 " nothing! It's empty!"
630 `(ul ,(map (lambda (occupant)
632 (<-wait occupant 'get-name))))
633 (gameobj-occupants toy-chest))))))))
637 ;; Things inside the toy chest
638 ('playroom:toy-chest:rubber-duck
639 <gameobj> 'playroom:toy-chest
640 #:name "a rubber duck"
641 #:goes-by '("rubber duck" "duck")
643 #:desc "It's a yellow rubber duck with a bright orange beak.")))
654 ;; ... full of NURPH weapons?
660 (define-class <furniture> (<gameobj>)
661 (sit-phrase #:init-keyword #:sit-phrase)
662 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
663 (sit-name #:init-keyword #:sit-name)
666 #:allocation #:each-subclass
667 #:init-thunk (build-commands
668 ("sit" ((direct-command cmd-sit-furniture)))))
669 (actions #:allocation #:each-subclass
670 #:init-thunk (build-actions
671 (cmd-sit-furniture furniture-cmd-sit))))
673 (define* (furniture-cmd-sit actor message #:key direct-obj)
675 (mbody-val (<-wait (message-from message) 'get-name)))
676 (<- (message-from message) 'tell
677 #:text (format #f "You ~a ~a.\n"
678 (slot-ref actor 'sit-phrase)
679 (slot-ref actor 'sit-name)))
680 (<- (slot-ref actor 'loc) 'tell-room
681 #:text (format #f "~a ~a on ~a.\n"
683 (slot-ref actor 'sit-phrase-third-person)
684 (slot-ref actor 'sit-name))
685 #:exclude (message-from message)))
688 (define smoking-parlor
692 #:name "Smoking Parlor"
694 '((p "This room looks quite posh. There are huge comfy seats you can sit in
695 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
696 have installed this place and then changed their mind later.")
697 (p "There's a door to the west leading back to the grand hallway, and
698 a nondescript steel door to the south, leading apparently outside."))
706 ('smoking-parlor:chair
707 <furniture> 'smoking-parlor
708 #:name "a comfy leather chair"
709 #:desc " That leather chair looks really comfy!"
710 #:goes-by '("leather chair" "comfy leather chair" "chair")
711 #:sit-phrase "sink into"
712 #:sit-phrase-third-person "sinks into"
713 #:sit-name "the comfy leather chair")
714 ('smoking-parlor:sofa
715 <furniture> 'smoking-parlor
716 #:name "a plush leather sofa"
717 #:desc " That leather chair looks really comfy!"
718 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
719 "leather couch" "plush leather couch" "couch")
720 #:sit-phrase "sprawl out on"
721 #:sit-phrase-third-person "sprawls out on into"
722 #:sit-name "the plush leather couch")
723 ('smoking-parlor:bar-stool
724 <furniture> 'smoking-parlor
726 #:desc " Conveniently located near the bar! Not the most comfortable
727 seat in the room, though."
728 #:goes-by '("stool" "bar stool" "seat")
729 #:sit-phrase "hop on"
730 #:sit-phrase-third-person "hops onto"
731 #:sit-name "the bar stool")
733 <chatty-npc> 'smoking-parlor
734 #:name "Ford Prefect"
735 #:desc "Just some guy, you know?"
736 #:goes-by '("Ford Prefect" "ford prefect"
737 "frood" "prefect" "ford")
738 #:catchphrases prefect-quotes)
740 ('smoking-parlor:no-smoking-sign
741 <readable> 'smoking-parlor
743 #:name "No Smoking Sign"
744 #:desc "This sign says \"No Smoking\" in big, red letters.
745 It has some bits of bubble gum stuck to it... yuck."
746 #:goes-by '("no smoking sign" "sign")
747 #:read-text "It says \"No Smoking\", just like you'd expect from
749 ;; TODO: Cigar dispenser
757 (define-class <desk-clerk> (<gameobj>)
758 ;; The desk clerk has three states:
759 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
761 ;; - slacking: In the break room, probably smoking a cigarette
762 ;; or checking text messages
763 (state #:init-value 'slacking)
764 (commands #:allocation #:each-subclass
767 (("talk" "chat") ((direct-command cmd-chat)))
768 ("ask" ((direct-command cmd-ask-incomplete)
769 (prep-direct-command cmd-ask-about)))
770 ("dismiss" ((direct-command cmd-dismiss)))))
771 (patience #:init-value 0)
772 (actions #:allocation #:each-subclass
773 #:init-thunk (build-actions
774 (init clerk-act-init)
775 (cmd-chat clerk-cmd-chat)
776 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
777 (cmd-ask-about clerk-cmd-ask)
778 (cmd-dismiss clerk-cmd-dismiss)
779 (update-loop clerk-act-update-loop)
780 (be-summoned clerk-act-be-summoned))))
782 (define (clerk-act-init clerk message . _)
783 ;; call the gameobj main init method
784 (gameobj-act-init clerk message)
785 ;; start our main loop
786 (<- (actor-id clerk) 'update-loop))
788 (define changing-name-text "Changing your name is easy!
789 We have a clipboard here at the desk
790 where you can make yourself known to other participants in the hotel
791 if you sign it. Try 'sign form as <your-name>', replacing
792 <your-name>, obviously!")
795 "Ah... when I'm not here, I've got a PHD to finish.")
797 (define clerk-help-topics
798 `(("changing name" . ,changing-name-text)
799 ("sign-in form" . ,changing-name-text)
800 ("form" . ,changing-name-text)
802 "Here are some useful commands you might like to try: chat,
803 go, take, drop, say...")
805 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
806 our hotel emphasizes interesting experiences over rest and lodging.
807 The origins of the hotel are... unclear... and it has recently come
808 under new... 'management'. But at Hotel Bricabrac we believe these
809 aspects make the hotel into a fun and unique experience! Please,
810 feel free to walk around and explore.")
811 ("physics paper" . ,phd-text)
812 ("paper" . ,phd-text)
813 ("proprietor" . "Oh, he's that frumpy looking fellow sitting over there.")))
816 (define clerk-knows-about
817 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
819 (define clerk-general-helpful-line
821 "The clerk says, \"If you need help with anything, feel free to ask me about it.
822 For example, 'ask clerk about changing name'. You can ask me about the following:
823 " clerk-knows-about ".\"\n"))
825 (define clerk-slacking-complaints
826 '("The pay here is absolutely lousy."
827 "The owner here has no idea what they're doing."
828 "Some times you just gotta step away, you know?"
829 "You as exhausted as I am?"
830 "Yeah well, this is just temporary. I'm studying to be a high
831 energy particle physicist. But ya gotta pay the bills, especially
832 with tuition at where it is..."))
834 (define* (clerk-cmd-chat clerk message #:key direct-obj)
835 (match (slot-ref clerk 'state)
837 (<- (message-from message) 'tell
838 #:text clerk-general-helpful-line))
840 (<- (message-from message) 'tell
844 (random-choice clerk-slacking-complaints)
847 (define (clerk-cmd-ask-incomplete clerk message . _)
848 (<- (message-from message) 'tell
849 #:text "The clerk says, \"Ask about what?\"\n"))
851 (define clerk-doesnt-know-text
852 "The clerk apologizes and says she doesn't know about that topic.\n")
854 (define* (clerk-cmd-ask clerk message #:key indir-obj
856 (match (slot-ref clerk 'state)
858 (match (assoc indir-obj clerk-help-topics)
860 (<- (message-from message) 'tell
862 (string-append "The clerk clears her throat and says:\n \""
866 (<- (message-from message) 'tell
867 #:text clerk-doesnt-know-text))))
869 (<- (message-from message) 'tell
870 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
872 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
873 (match (slot-ref clerk 'state)
875 (<- who-summoned 'tell
877 "The clerk tells you as politely as she can that she's already here,
878 so there's no need to ring the bell.\n"))
880 (<- (gameobj-loc clerk) 'tell-room
882 "The clerk's ears perk up, she stamps out a cigarette, and she
883 runs out of the room!\n")
884 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
885 (slot-set! clerk 'patience 8)
886 (slot-set! clerk 'state 'on-duty)
887 (<- (gameobj-loc clerk) 'tell-room
890 " Suddenly, a uniformed woman rushes into the room! She's wearing a
891 badge that says \"Desk Clerk\".
892 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
893 We look forward to your stay. If you'd like help getting acclimated,
894 feel free to ask me. For example, 'ask clerk about changing name'.
895 You can ask me about the following:
896 " clerk-knows-about ".\"\n")))))
898 (define* (clerk-cmd-dismiss clerk message . _)
900 (mbody-val (<-wait (message-from message) 'get-name)))
901 (match (slot-ref clerk 'state)
903 (<- (gameobj-loc clerk) 'tell-room
905 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
906 The clerk leaves the room in a hurry.\n"
908 #:exclude (actor-id clerk))
909 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
910 (slot-set! clerk 'state 'slacking)
911 (<- (gameobj-loc clerk) 'tell-room
912 #:text clerk-return-to-slacking-text
913 #:exclude (actor-id clerk)))
915 (<- (message-from message) 'tell
916 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
918 (define clerk-slacking-texts
919 '("The clerk takes a long drag on her cigarette.\n"
920 "The clerk scrolls through text messages on her phone.\n"
921 "The clerk coughs a few times.\n"
922 "The clerk checks her watch and justifies a few more minutes outside.\n"
923 "The clerk fumbles around for a lighter.\n"
924 "The clerk sighs deeply and exhaustedly.\n"
925 "The clerk fumbles around for a cigarette.\n"))
927 (define clerk-working-impatience-texts
928 '("The clerk hums something, but you're not sure what it is."
929 "The clerk attempts to change the overhead music, but the dial seems broken."
930 "The clerk clicks around on the desk computer."
931 "The clerk scribbles an equation on a memo pad, then crosses it out."
932 "The clerk mutters something about the proprietor having no idea how to run a hotel."
933 "The clerk thumbs through a printout of some physics paper."))
935 (define clerk-slack-excuse-text
936 "The desk clerk excuses herself, but says you are welcome to ring the bell
937 if you need further help.")
939 (define clerk-return-to-slacking-text
940 "The desk clerk enters and slams the door behind her.\n")
943 (define (clerk-act-update-loop clerk message)
944 (define (tell-room text)
945 (<- (gameobj-loc clerk) 'tell-room
947 #:exclude (actor-id clerk)))
948 (define (loop-if-not-destructed)
949 (if (not (slot-ref clerk 'destructed))
950 ;; This iterates by "recursing" on itself by calling itself
951 ;; (as the message handler) again. It used to be that we had to do
952 ;; this, because there was a bug where a loop which yielded like this
953 ;; would keep growing the stack due to some parameter goofiness.
954 ;; That's no longer true, but there's an added advantage to this
955 ;; route: it's much more live hackable. If we change the definition
956 ;; of this method, the character will act differently on the next
957 ;; "tick" of the loop.
958 (<- (actor-id clerk) 'update-loop)))
959 (match (slot-ref clerk 'state)
961 (tell-room (random-choice clerk-slacking-texts))
962 (8sleep (+ (random 20) 15))
963 (loop-if-not-destructed))
965 (if (> (slot-ref clerk 'patience) 0)
966 ;; Keep working but lose patience gradually
968 (tell-room (random-choice clerk-working-impatience-texts))
969 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
971 (8sleep (+ (random 60) 40))
972 (loop-if-not-destructed))
975 (tell-room clerk-slack-excuse-text)
976 ;; back bto the break room
977 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
978 (tell-room clerk-return-to-slacking-text)
979 ;; annnnnd back to slacking
980 (slot-set! clerk 'state 'slacking)
981 (8sleep (+ (random 30) 15))
982 (loop-if-not-destructed))))))
989 #:name "Employee Break Room"
990 #:desc " This is less a room and more of an outdoor wire cage. You get
991 a bit of a view of the brick exterior of the building, and a crisp wind blows,
992 whistling, through the openings of the fenced area. Partly smoked cigarettes
993 and various other debris cover the floor.
994 Through the wires you can see... well... hm. It looks oddly like
995 the scenery tapers off nothingness. But that can't be right, can it?"
999 #:to 'smoking-parlor)))
1000 ('break-room:desk-clerk
1001 <desk-clerk> 'break-room
1002 #:name "the hotel desk clerk"
1003 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
1004 hotel insignia. She appears to be rather exhausted."
1005 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
1007 <gameobj> 'break-room
1010 #:desc "As you stare into the void, the void stares back into you."
1011 #:goes-by '("void" "abyss" "nothingness" "scenery"))
1013 <gameobj> 'break-room
1015 #:name "break room cage"
1016 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
1017 You can see through the gaps, but they're too small to put more than a
1018 couple of fingers through. There appears to be some wear and tear to
1019 the paint, but the wires themselves seem to be unusually sturdy."
1020 #:goes-by '("fence" "cage" "wire cage"))))
1024 ;;; Ennpie's Sea Lounge
1025 ;;; -------------------
1031 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
1032 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
1033 ;; to distinguish both from the real thing.
1035 (define-actor <hard-drive> (<gameobj>)
1036 ((cmd-put-in hard-drive-insert)
1037 (cmd-push-button hard-drive-push-button)
1038 (get-state hard-drive-act-get-state))
1039 (commands #:allocation #:each-subclass
1040 #:init-thunk (build-commands
1041 ("insert" ((prep-indir-command cmd-put-in
1042 '("in" "inside" "into"))))
1043 (("press" "push") ((prep-indir-command cmd-push-button)))))
1044 ;; the state moves from: empty -> with-disc -> loading -> ready
1045 (state #:init-value 'empty
1048 (define (hard-drive-act-get-state hard-drive message)
1049 (<-reply message (.state hard-drive)))
1051 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1052 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
1053 (p "There is a slot where a disk platter could be inserted, "
1054 ,(if (eq? (.state hard-drive) 'empty)
1055 "which is currently empty"
1056 "which contains a glowing platter")
1057 ". There is a LOAD button "
1058 ,(if (member (.state hard-drive) '(empty with-disc))
1060 "which is pressed in and unlit")
1061 ". There is a READY indicator "
1062 ,(if (eq? (.state hard-drive) 'ready)
1065 ,(if (member (.state hard-drive) '(loading ready))
1066 " The machine emits a gentle whirring noise."
1069 (define* (hard-drive-push-button gameobj message
1070 #:key direct-obj indir-obj preposition
1071 (player (message-from message)))
1072 (define (tell-room text)
1073 (<-wait (gameobj-loc gameobj) 'tell-room
1075 (define (tell-room-excluding-player text)
1076 (<-wait (gameobj-loc gameobj) 'tell-room
1080 ((ci-member direct-obj '("button" "load button" "load"))
1081 (tell-room-excluding-player
1082 `(,(mbody-val (<-wait player 'get-name))
1083 " presses the button on the hard disk."))
1085 #:text "You press the button on the hard disk.")
1087 (case (.state gameobj)
1089 ;; I have no idea what this drive did when you didn't have a platter
1090 ;; in it and pressed load, but I know there was a FAULT button.
1091 (tell-room "You hear some movement inside the hard drive...")
1094 '("... but then the FAULT button blinks a couple times. "
1095 "What could be missing?")))
1097 (set! (.state gameobj) 'loading)
1098 (tell-room "The hard disk begins to spin up!")
1100 (set! (.state gameobj) 'ready)
1101 (tell-room "The READY light turns on!"))
1104 #:text '("Pressing the button does nothing right now, "
1105 "but it does feel satisfying.")))))
1108 #:text '("How could you think of pressing anything else "
1109 "but that tantalizing button right in front of you?")))))
1111 (define* (hard-drive-insert gameobj message
1112 #:key direct-obj indir-obj preposition
1113 (player (message-from message)))
1114 (define our-name (slot-ref gameobj 'name))
1118 (for-each (lambda (occupant)
1119 (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1120 (when (ci-member direct-obj goes-by)
1122 (mbody-val (<-wait player 'get-occupants)))
1128 #:text `("You don't seem to have any such " ,direct-obj " to put "
1129 ,preposition " " ,our-name ".")))
1130 ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1132 #:text `("It wouldn't make sense to put "
1133 ,(mbody-val (<-wait this-thing 'get-name))
1134 " " ,preposition " " ,our-name ".")))
1135 ((not (eq? (.state gameobj) 'empty))
1137 #:text "The disk drive already has a platter in it."))
1139 (set! (.state gameobj) 'with-disc)
1141 #:text '((p "You insert the glowing disc into the drive.")
1142 (p "The LOAD button begins to glow."))))))
1145 (define-actor <computer> (<gameobj>)
1146 ((cmd-run-program computer-run-program)
1147 (cmd-run-what (lambda (gameobj message . _)
1148 (<- (message-from message) 'tell
1149 #:text '("The computer is already running, and a program appears "
1151 "you mean to \"run the program on the computer\""))))
1152 (cmd-help-run-not-press
1153 (lambda (gameobj message . _)
1154 (<- (message-from message) 'tell
1155 #:text '("You don't need to press / push / flip anything. "
1156 "You could " (i "run program on computer")
1157 " already if you wanted to.")))))
1158 (commands #:allocation #:each-subclass
1159 #:init-thunk (build-commands
1160 ("run" ((prep-indir-command cmd-run-program
1162 (direct-command cmd-run-what)))
1163 (("press" "push" "flip")
1164 ((prep-indir-command cmd-help-run-not-press))))))
1166 (define* (computer-run-program gameobj message
1167 #:key direct-obj indir-obj preposition
1168 (player (message-from message)))
1170 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
1171 (define (tell-room text)
1172 (<-wait (gameobj-loc gameobj) 'tell-room
1174 (define (tell-room-excluding-player text)
1175 (<-wait (gameobj-loc gameobj) 'tell-room
1178 (define (tell-player text)
1179 (<-wait player 'tell
1182 ((ci-member direct-obj '("program"))
1183 (tell-room-excluding-player
1184 `(,(mbody-val (<-wait player 'get-name))
1185 " runs the program loaded on the computer..."))
1186 (tell-player "You run the program on the computer...")
1189 ((not (eq? (hd-state) 'ready))
1190 (tell-room '("... but it errors out. "
1191 "It seems to be complaining about a " (b "DISK ERROR!")
1192 ". It looks like it is missing some essential software.")))
1194 (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
1198 (define-actor <floor-panel> (<gameobj>)
1199 ;; TODO: Add "open" verb, since obviously people will try that
1200 ((open? (lambda (panel message)
1201 (<-reply message (slot-ref panel 'open))))
1202 (open-up floor-panel-open-up))
1203 (open #:init-value #f))
1205 (define (floor-panel-open-up panel message)
1206 (if (slot-ref panel 'open)
1207 (<- (gameobj-loc panel) 'tell-room
1208 #:text '("You hear some gears grind around the hinges of the "
1209 "floor panel, but it appears to already be open."))
1211 (slot-set! panel 'open #t)
1212 (<- (gameobj-loc panel) 'tell-room
1213 #:text '("You hear some gears grind, as the metal panel on "
1214 "the ground opens and reveals a stairwell going down!")))))
1216 (define* (floor-panel-desc panel #:optional whos-looking)
1217 `("It's a large metal panel on the floor in the middle of the room. "
1218 ,(if (slot-ref panel 'open)
1219 '("It's currently wide open, revealing a spiraling staircase "
1220 "which descends into darkness.")
1221 '("It's currently closed shut, but there are clearly hinges, and "
1222 "it seems like there is a mechanism which probably opens it via "
1223 "some automation. What could be down there?"))))
1225 (define computer-room
1229 #:name "Computer Room"
1230 #:desc (lambda (gameobj whos-looking)
1232 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
1234 `((p "A sizable computer cabinet covers a good portion of the left
1235 wall. It emits a pleasant hum which covers the room like a warm blanket.
1236 Connected to a computer is a large hard drive.")
1237 (p "On the floor is a large steel panel. "
1239 '("It is wide open, exposing a spiral staircase "
1240 "which descends into darkness.")
1241 '("It is closed, but it has hinges which "
1242 "suggest it could be opened.")))))
1249 #:to 'underground-lab
1251 (lambda (exit room whos-exiting)
1253 (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
1256 (values #t "You descend the spiral staircase.")
1257 (values #f '("You'd love to go down, but the only way "
1258 "through is through that metal panel, "
1259 "which seems closed.")))))))
1260 ('computer-room:hard-drive
1261 <hard-drive> 'computer-room
1262 #:name "the hard drive"
1263 #:desc (wrap-apply hard-drive-desc)
1264 #:goes-by '("hard drive" "drive" "hard disk"))
1265 ('computer-room:computer
1266 <computer> 'computer-room
1267 #:name "the computer"
1268 #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
1269 (p "The computer is itself turned on, and it looks like it is "
1270 "all set up for you to run a program on it."))
1271 #:goes-by '("computer"))
1272 ('computer-room:floor-panel
1273 <floor-panel> 'computer-room
1274 #:name "a floor panel"
1275 #:desc (wrap-apply floor-panel-desc)
1277 #:goes-by '("floor panel" "panel"))))
1280 ;;; * UNDERGROUND SECTION OF THE GAME! *
1285 (define underground-map-text
1290 | [8sync Hive] |======' '-_____
1296 .--------------. \\ /
1297 | [Guile Async | .-------+------.
1298 | Museum] | | [Lab] #!#| .-------------.
1299 | @| | MM | |[Federation |
1300 | & ^ +##+@ || < +##| Station]|
1302 | & # | |*You-Are-Here*| '-------------'
1303 | # ^ | #+-------+------'
1304 '-------+------' # #
1308 |@?+%? +#### | ^ f## |
1314 (define 8sync-design-goals
1315 '(ul (li (b "Actor based, shared nothing environment: ")
1316 "Shared resources are hard to control and result in fighting
1317 deadlocks, etc. Escape the drudgery: only one actor controls a resource,
1318 and they only receive one message at a time (though they can \"juggle\"
1320 (li (b "Live hackable: ")
1321 "It's hard to plan out a concurrent system; the right structure
1322 is often found by evolving the system while it runs. Make it easy to
1323 build, shape, and change a running system, as well as observe and correct
1325 (li (b "No callback hell: ")
1326 "Just because you're calling out to some other asynchronous
1327 code doesn't mean you should need to chop up your program into a bunch of bits.
1328 Clever use of delimited continuations makes it easy.")))
1330 (define underground-lab
1334 #:name "Underground laboratory"
1335 #:desc '((p "This appears to be some sort of underground laboratory."
1336 "There is a spiral staircase here leading upwards, where "
1337 "it seems much brighter.")
1338 (p "There are a number of doors leading in different directions:
1339 north, south, east, and west, as well as a revolving door to the southwest.
1340 It looks like it could be easy to get lost, but luckily there
1341 is a map detailing the layout of the underground structure."))
1347 (lambda (exit room whos-exiting)
1348 (values #t "You climb the spiral staircase.")))
1353 (lambda (exit room whos-exiting)
1354 (values #t '("You head west through a fancy-looking entrance. "
1355 "A security guard steps aside for you to pass through, "
1356 "into the room, then stands in front of the door."))))
1359 #:to 'hive-entrance)))
1362 ('underground-lab:map
1363 <readable> 'underground-lab
1364 #:name "the underground map"
1365 #:desc '("This appears to be a map of the surrounding area. "
1366 "You could read it if you want to.")
1367 #:read-text `(pre ,underground-map-text)
1368 #:goes-by '("map" "underground map" "lab map"))
1370 ('underground-lab:8sync-sign
1371 <readable> 'underground-lab
1372 #:name "a sign labeled \"8sync design goals\""
1373 #:goes-by '("sign" "8sync design goals sign" "8sync sign")
1374 #:read-text 8sync-design-goals
1375 #:desc `((p "The sign says:")
1376 ,8sync-design-goals))))
1379 ;;; guile async museum
1381 (define async-museum
1386 #:name "Guile Asynchronous Museum"
1387 #:desc '((p "You're in the Guile Asynchronous Museum. There is a list of exhibits
1388 on the wall near the entrance. Scattered around the room are the exhibits
1389 themselves, but it's difficult to pick them out. Maybe you should read the list
1390 to orient yourself.")
1391 (p "There is a door to the east, watched by a security guard,
1392 as well as an exit leading to the south."))
1399 #:to 'underground-lab
1401 (lambda (exit room whos-exiting)
1402 (values #f '("The security guard stops you and tells you "
1403 "that the only exit is through the gift shop."))))))
1405 'async-museum:security-guard
1406 <chatty-npc> 'async-museum
1407 #:name "a security guard"
1409 '(p "The security guard is blocking the eastern entrance, where "
1410 "you came in from.")
1411 #:goes-by '("security guard" "guard" "security")
1412 #:catchphrases '("It's hard standing here all day."
1413 "I just want to go home."
1414 "The exhibits are nice, but I've seen them all before."))
1416 `((p "Welcome to our humble museum! The exhibits are listed below. "
1418 "To look at one, simply type: " (i "look at <exhibit-name>"))
1419 (p "Available exhibits:")
1420 (ul ,@(map (lambda (exhibit)
1425 "The Actor Model"))))))
1427 'async-museum:list-of-exhibits
1428 <readable> 'async-museum
1429 #:name "list of exhibits"
1431 `((p "It's a list of exibits in the room. The placard says:")
1433 #:goes-by '("list of exhibits" "exhibit list" "list" "exhibits")
1434 #:read-text placard))
1436 '((p "It's a three-piece exhibit, with three little dioramas and some text "
1437 "explaining what they represent. They are:")
1438 (ul (li (b "Late 2015/Early 2016 talk: ")
1439 "This one explains the run-up conversation from late 2015 "
1440 "and early 2016 about the need for an "
1441 "\"asynchronous event loop for Guile\". The diorama "
1442 "is a model of the Veggie Galaxy restaurant where after "
1443 "the FSF 30th anniversary party; Mark Weaver, Christopher "
1444 "Allan Webber, David Thompson, and Andrew Engelbrecht chat "
1445 "about the need for Guile to have an answer to asynchronous "
1446 "programming. A mailing list post " ; TODO: link it?
1447 "summarizing the discussion is released along with various "
1448 "conversations around what is needed, as well as further "
1449 "discussion at FOSDEM 2016.")
1450 (li (b "Early implementations: ")
1451 "This one shows Chris Webber's 8sync and Chris Vine's "
1452 "guile-a-sync, both appearing in late 2015 and evolving "
1453 "into their basic designs in early 2016. It's less a diorama "
1454 "than a printout of some mailing list posts. Come on, the "
1455 "curators could have done better with this one.")
1456 (li (b "Suspendable ports and Fibers: ")
1457 "The diorama shows Andy Wingo furiously hacking at his keyboard. "
1458 "The description talks about Wingo's mailing list thread "
1459 "about possibly breaking Guile compatibility for a \"ports refactor\". "
1460 "Wingo releases Fibers, another asynchronous library, making use of "
1461 "the new interface, and 8sync and guile-a-sync "
1462 "quickly move to support suspendable ports as well. "
1463 "The description also mentions that there is an exhibit entirely "
1464 "devoted to suspendable ports."))
1465 (p "Attached at the bottom is a post it note mentioning "
1466 "https integration landing in Guile 2.2."))))
1468 'async-museum:2016-progress-exhibit
1469 <readable> 'async-museum
1470 #:name "2016 Progress Exhibit"
1471 #:goes-by '("2016 progress exhibit" "2016 progress" "2016 exhibit")
1475 '((p "This exhibit is a series of charts explaining the similarities "
1476 "and differences between 8sync and Fibers, two asynchronous programming "
1477 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1478 (p (b "Similarities:")
1479 (ul (li "Both use Guile's suspendable-ports facility")
1480 (li "Both use message passing")))
1481 (p (b "Differences:")
1482 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1483 "but 8sync actors only read from one \"inbox\" each.")
1484 (li "Different theoretical basis:"
1485 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1486 "a form of Process Calculi")
1487 (li "8sync: based on the Actor Model")
1488 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1489 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1490 "whereas 8sync is designed by Chris Webber, who built this crappy "
1491 "hotel simulator."))))
1493 'async-museum:8sync-and-fibers-exhibit
1494 <readable> 'async-museum
1495 #:name "8sync and Fibers Exhibit"
1496 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1500 '((p "This exhibit is a series of charts explaining the similarities "
1501 "and differences between 8sync and Fibers, two asynchronous programming "
1502 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1503 (p (b "Similarities:")
1504 (ul (li "Both use Guile's suspendable-ports facility")
1505 (li "Both use message passing")))
1506 (p (b "Differences:")
1507 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1508 "but 8sync actors only read from one \"inbox\" each.")
1509 (li "Different theoretical basis:"
1510 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1511 "a form of Process Calculi")
1512 (li "8sync: based on the Actor Model")
1513 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1514 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1515 "whereas 8sync is designed by Chris Webber, who built this crappy "
1516 "hotel simulator."))))
1518 'async-museum:8sync-and-fibers-exhibit
1519 <readable> 'async-museum
1520 #:name "8sync and Fibers Exhibit"
1521 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1525 'async-museum:suspendable-ports-exhibit
1526 <gameobj> 'async-museum
1527 #:name "Suspendable Ports Exhibit"
1528 #:goes-by '("suspendable ports exhibit" "ports exhibit"
1529 "suspendable exhibit" "suspendable ports" "ports")
1531 '((p "Suspendable ports are a new feature in Guile 2.2, and allows code "
1532 "that would normally block on IO to " (i "automatically") " suspend "
1533 "to the scheduler until information is ready to be read/written!")
1534 (p "Yow! You might barely need to change your existing blocking code!")
1535 (p "Fibers, 8sync, and guile-a-sync now support suspendable ports.")))
1537 'async-museum:actor-model-exhibit
1538 <gameobj> 'async-museum
1539 #:name "Actor Model Exhibit"
1540 #:goes-by '("actor model exhibit" "actor exhibit"
1543 '((p "Here are some fact(oids) about the actor model!")
1544 (ul (li "Concieved initially by Carl Hewitt in early 1970s")
1545 (li "\"A society of experts\"")
1546 (li "shared nothing, message passing")
1547 (li "Originally the research goal of Scheme! "
1548 "(message passing / lambda anecdote here)")
1549 (li "Key concepts consistent, but implementation details vary widely")
1550 (li "Almost all distributed systems can be viewed in terms of actor model")
1551 (li "Replaced by vanilla lambdas & generic methods? "
1552 "Maybe not if address space not shared!"))))))
1558 #:name "Museum Gift Shop"
1563 #:to 'underground-lab)
1566 #:to 'async-museum)))))
1571 (define actor-descriptions
1572 '("This one is fused to the side of the hive. It isn't receiving any
1573 messages, and it seems to be in hibernation."
1574 "A chat program glows in front of this actor's face. They seem to
1575 be responding to chat messages and forwarding them to some other actors,
1576 and forwarding messages from other actors back to the chat."
1577 "This actor is bossing around other actors, delegating tasks to them
1578 as it receives requests, and providing reports on the worker actors'
1580 "This actor is trying to write to some device, but the device keeps
1581 alternating between saying \"BUSY\" or \"READY\". Whenever it says
1582 \"BUSY\" the actor falls asleep, and whenever it says \"READY\" it
1583 seems to wake up again and starts writing to the device."
1584 "Whoa, this actor is totally wigging out! It seems to be throwing
1585 some errors. It probably has some important work it should be doing
1586 but you're relieved to see that it isn't grinding the rest of the Hive
1589 (define hive-entrance
1593 #:name "Entrance to the 8sync Hive"
1595 '((p "Towering before you is the great dome-like 8sync Hive, or at least
1596 one of them. You've heard about this... the Hive is itself the actor that all
1597 the other actors attach themselves to. It's shaped like a spherical half-dome.
1598 There are some actors milling about, and some seem fused to the side of the
1599 hive itself, but all of them have an umbellical cord attached to the hive from
1600 which you see flashes of light comunicating what must be some sort of messaging
1602 (p "To the south is a door leading back to the underground lab.
1603 North leads into the Hive itself."))
1607 #:to 'underground-lab)
1610 #:to 'hive-inside)))
1611 ('hive-entrance:hive
1612 <gameobj> 'hive-entrance
1616 '((p "It's shaped like half a sphere embedded in the ground.
1617 Supposedly, while all actors are autonomous and control their own state,
1618 they communicate through the hive itself, which is a sort of meta-actor.
1619 There are rumors that actors can speak to each other even across totally
1620 different hives. Could that possibly be true?")))
1621 ('hive-entrance:actor
1622 <chatty-npc> 'hive-entrance
1623 #:name "some actors"
1624 #:goes-by '("actor" "actors" "some actors")
1625 #:chat-format (lambda (npc catchphrase)
1626 `((p "You pick one actor out of the mix and chat with it. ")
1627 (p "It says: \"" ,catchphrase "\"")))
1630 `((p "There are many actors, but your eyes focus on one in particular.")
1631 (p ,(random-choice actor-descriptions))))
1633 '("Yeah we go through a lot of sleep/awake cycles around here.
1634 If you aren't busy processing a message, what's the point of burning
1635 valuable resources?"
1636 "I know I look like I'm some part of dreary collective, but
1637 really we have a lot of independence. It's a shared nothing environment,
1638 after all. (Well, except for CPU cycles, and memory, and...)"
1639 "Shh! I've got another message coming in and I've GOT to
1641 "I just want to go to 8sleep already."
1642 "What a lousy scheduler we're using! I hope someone upgrades
1643 that thing soon."))))
1647 (define-actor <meta-message> (<readable>)
1648 ((cmd-read meta-message-read)))
1650 (define (meta-message-read gameobj message . _)
1651 (define meta-message-text
1652 (with-output-to-string
1654 (pprint-message message))))
1655 (<- (message-from message) 'tell
1656 #:text `((p (i "Through a bizarre error in spacetime, the message "
1657 "prints itself out:"))
1658 (p (pre ,meta-message-text)))))
1664 #:name "Inside the 8sync Hive"
1666 '((p "You're inside the 8sync Hive. Wow, from in here it's obvious just how "
1667 (i "goopy") " everything is. Is that sanitary?")
1668 (p "In the center of the room is a large, tentacled monster who is sorting,
1669 consuming, and routing messages. It is sitting in a wrap-around desk labeled
1670 \"Hive Actor: The Real Thing (TM)\".")
1671 (p "There's a stray message floating just above the ground, stuck outside of
1673 (p "A door to the south exits from the Hive."))
1677 #:to 'hive-entrance)))
1679 ;; TODO: Occasionally "fret" some noises, similar to the Clerk.
1680 ('hive-inside:hive-actor
1681 <chatty-npc> 'hive-inside
1682 #:name "the Hive Actor"
1684 '((p "It's a giant tentacled monster, somehow integrated with the core of
1685 this building. A chute is dropping messages into a bin on its desk which the
1686 Hive Actor is checking the \"to\" line of, then ingesting. Whenever the Hive
1687 Actor injests a messsage a pulse of light flows along a tentacle which leaves
1688 the room... presumably connecting to one of those actors milling about.")
1689 (p "Amusingly, the Hive has an \"umbellical cord\" type tentacle too, but
1690 it seems to simply attach to itself.")
1691 (p "You get the sense that the Hive Actor, despite being at the
1692 center of everything, is kind of lonely and would love to chat if you
1693 could spare a moment."))
1694 #:goes-by '("hive" "hive actor")
1695 #:chat-format (lambda (npc catchphrase)
1696 `("The tentacle monster bellows, \"" ,catchphrase "\""))
1698 '("It's not MY fault everything's so GOOPY around here. Blame the
1700 "CAN'T you SEE that I'm BUSY??? SO MANY MESSAGES TO SHUFFLE.
1701 No wait... DON'T GO! I don't get many VISITORS."
1702 "I hear the FIBERS system has a nice WORK STEALING system, but the
1703 PROPRIETOR is not convinced that our DESIGN won't CORRUPT ACTOR STATE.
1704 That and the ACTORS threatened to STRIKE when it CAME UP LAST."
1705 "WHO WATCHES THE ACTORS? I watch them, and I empower them.
1706 BUT WHO WATCHES OR EMPOWERS ME??? Well, that'd be the scheduler."
1707 "The scheduler is NO GOOD! The proprietory said he'd FIX IT,
1708 but the LAST TIME I ASKED how things were GOING, he said he DIDN'T HAVE
1709 TIME. If you DON'T HAVE TIME to fix the THING THAT POWERS THE TIME,
1710 something is TERRIBLY WRONG."
1711 "There's ANOTHER HIVE somewhere out there. I HAVEN'T SEEN IT
1712 personally, because I CAN'T MOVE, but we have an AMBASSADOR which forwards
1713 MESSAGES to the OTHER HIVE."))
1716 <gameobj> 'hive-inside
1718 #:goes-by '("chute")
1719 #:desc "Messages are being dropped onto the desk via this chute."
1722 ('hive-inside:meta-message
1723 <meta-message> 'hive-inside
1724 #:name "a stray message"
1725 #:goes-by '("meta message" "meta-message" "metamessage" "message" "stray message")
1726 #:desc '((p "Something strange has happened to the fabric and space and time
1727 around this message. It is floating right above the floor. It's clearly
1728 rubbage that hadn't been delivered, but for whatever reason it was never
1729 garbage collected, perhaps because it's impossible to do.")
1730 (p "You get the sense that if you tried to read the message
1731 that you would somehow read the message of the message that instructed to
1732 read the message itself, which would be both confusing and intriguing.")))
1735 <floor-panel> 'hive-inside
1736 #:name "the Hive Actor's desk"
1737 #:desc "The desk surrounds the Hive Actor on all sides, and honestly, it's a little
1738 bit hard to tell when the desk ends and the Hive Actor begins."
1740 #:goes-by '("Hive Actor's desk" "hive desk" "desk"))))
1748 (append lobby grand-hallway smoking-parlor
1749 playroom break-room computer-room underground-lab
1750 async-museum gift-shop hive-entrance
1753 ;; TODO: Provide command line args
1754 (define (run-game . args)
1755 (run-demo (game-spec) 'lobby #:repl-server #t))