1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016, 2017 Christine Lemmer-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 is just where reading is the same thing as looking
66 (define-class <readable-desc> (<gameobj>)
68 #:allocation #:each-subclass
69 #:init-thunk (build-commands
70 ("read" ((direct-command cmd-look-at))))))
72 ;; This one allows you to take from items that are proxied by it
73 (define-actor <proxy-items> (<gameobj>)
74 ((cmd-take-from take-from-proxy))
75 (proxy-items #:init-keyword #:proxy-items))
77 (define* (take-from-proxy gameobj message
78 #:key direct-obj indir-obj preposition
79 (player (message-from message)))
84 (define obj-id (dyn-ref gameobj obj-sym))
86 (mbody-val (<-wait obj-id 'goes-by)))
87 (when (ci-member direct-obj goes-by)
88 (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
90 (slot-ref gameobj 'proxy-items))
93 #:text `("You don't see any such " ,direct-obj " to take "
94 ,preposition " " ,(slot-ref gameobj 'name) ".")))))
101 (define (npc-chat-randomly actor message . _)
103 (random-choice (slot-ref actor 'catchphrases)))
105 ((slot-ref actor 'chat-format) actor catchphrase))
106 (<- (message-from message) 'tell
107 #:text text-to-send))
109 (define hotel-owner-grumps
110 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
111 "Don't mind the mess. I built this place on a dare, you
113 "(*tearfully*) Here, take this parenthesis. May it serve
115 "I gotta get back to the goblin farm soon..."
116 "Oh, but I was going to make a mansion... a great,
117 beautiful mansion! Full of ghosts! Now all I have is this cruddy
118 mo... hotel. Oh... If only I had more time!"
119 "I told them to paint more of the walls purple.
120 Why didn't they listen?"
121 "Listen to that overhead muzak. Whoever made that doesn't
122 know how to compose very well! Have you heard of the bands 'fmt'
123 or 'skribe'? Now *that's* composition!"))
125 (define-class <chatty-npc> (<gameobj>)
126 (catchphrases #:init-value '("Blarga blarga blarga!")
127 #:init-keyword #:catchphrases)
128 (chat-format #:init-value (lambda (npc catchphrase)
129 `(,(slot-ref npc 'name) " says: \""
131 #:init-keyword #:chat-format)
133 #:allocation #:each-subclass
134 #:init-thunk (build-commands
135 (("chat" "talk") ((direct-command cmd-chat)))))
136 (actions #:allocation #:each-subclass
139 (cmd-chat npc-chat-randomly))))
141 (define-class <sign-in-form> (<gameobj>)
143 #:allocation #:each-subclass
144 #:init-thunk (build-commands
145 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
147 (actions #:allocation #:each-subclass
148 #:init-thunk (build-actions
149 (cmd-sign-form sign-cmd-sign-in))))
153 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
155 (define forbidden-words
156 (append article preposition
157 '("and" "or" "but" "admin")))
159 (define (valid-name? name)
160 (and (irregex-match name-sre name)
161 (not (member name forbidden-words))))
163 (define* (sign-cmd-sign-in actor message
164 #:key direct-obj indir-obj preposition)
166 (mbody-val (<-wait (message-from message) 'get-name)))
167 (define name indir-obj)
168 (if (valid-name? indir-obj)
170 (<-wait (message-from message) 'set-name! name)
171 (<- (slot-ref actor 'loc) 'tell-room
172 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
173 old-name old-name name)))
174 (<- (message-from message) 'tell
175 #:text "Sorry, that's not a valid name.
176 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
180 (define-class <summoning-bell> (<gameobj>)
181 (summons #:init-keyword #:summons)
184 #:allocation #:each-subclass
185 #:init-thunk (build-commands
186 ("ring" ((direct-command cmd-ring)))))
187 (actions #:allocation #:each-subclass
188 #:init-thunk (build-actions
189 (cmd-ring summoning-bell-cmd-ring))))
191 (define* (summoning-bell-cmd-ring bell message . _)
192 ;; Call back to actor who invoked this message handler
193 ;; and find out their name. We'll call *their* get-name message
194 ;; handler... meanwhile, this procedure suspends until we get
197 (mbody-val (<-wait (message-from message) 'get-name)))
199 ;; Now we'll invoke the "tell" message handler on the player
200 ;; who rang us, displaying this text on their screen.
201 ;; This one just uses <- instead of <-wait, since we don't
202 ;; care when it's delivered; we're not following up on it.
203 (<- (message-from message) 'tell
204 #:text "*ring ring!* You ring the bell!\n")
205 ;; We also want everyone else in the room to "hear" the bell,
206 ;; but they get a different message since they aren't the ones
207 ;; ringing it. Notice here's where we make use of the invoker's
208 ;; name as extracted and assigned to the who-rang variable.
209 ;; Notice how we send this message to our "location", which
210 ;; forwards it to the rest of the occupants in the room.
211 (<- (gameobj-loc bell) 'tell-room
213 (format #f "*ring ring!* ~a rings the bell!\n"
215 #:exclude (message-from message))
216 ;; Now we perform the primary task of the bell, which is to summon
217 ;; the "clerk" character to the room. (This is configurable,
218 ;; so we dynamically look up their address.)
219 (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
220 #:who-summoned (message-from message)))
223 (define prefect-quotes
224 '("I'm a frood who really knows where my towel is!"
225 "On no account allow a Vogon to read poetry at you."
226 "Time is an illusion, lunchtime doubly so!"
227 "How can you have money if none of you produces anything?"
228 "On no account allow Arthur to request tea on this ship."))
230 (define-class <cabinet-item> (<gameobj>)
231 (take-me? #:init-value
234 `("Hm, well... the cabinet is locked and the properitor "
235 "is right over there.")))))
243 '((p "You're in some sort of hotel lobby. You see a large sign hanging "
244 "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
245 "that says \"'ring bell' for service\". Terrible music plays from a speaker "
246 "somewhere overhead. "
247 "The room is lined with various curio cabinets, filled with all sorts "
248 "of kitschy junk. It looks like whoever decorated this place had great "
249 "ambitions, but actually assembled it all in a hurry and used whatever "
250 "kind of objects they found lying around.")
251 (p "There's a door to the north leading to some kind of hallway."))
255 #:to 'grand-hallway)))
259 #:name "a languid lady"
261 '((p " Whoever this is, she looks totally exhausted. She's
262 collapsed into the only comfortable looking chair in the room and you
263 don't get the sense that she's likely to move any time soon.
264 Attached to her frumpy dress is a barely secured pin which says
265 \"Hotel Proprietor\", but she looks so disorganized that you think
266 that can't possibly be true... can it?
267 Despite her exhaustion, you sense she'd be happy to chat with you,
268 though the conversation may be a bit one sided."))
269 #:goes-by '("languid lady" "lady"
270 "hotel proprietor" "proprietor")
271 #:catchphrases hotel-owner-grumps)
275 #:name "the Hotel Bricabrac sign"
276 #:desc " It strikes you that there's something funny going on with this sign.
277 Sure enough, if you look at it hard enough, you can tell that someone
278 hastily painted over an existing sign and changed the \"M\" to an \"H\".
280 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
284 "hotel bricabrac sign"
288 <summoning-bell> 'lobby
289 #:name "a shiny brass bell"
290 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
291 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
292 \"ring me for service\". You probably could \"ring the bell\" if you
294 #:summons 'break-room:desk-clerk)
297 <sign-in-form> 'lobby
298 #:name "sign-in form"
299 #:goes-by '("sign-in form" "form" "signin form")
300 #:desc '("It looks like you could sign this form and set your name like so: "
301 (i "sign form as <my-name-here>")))
303 ;; Object: curio cabinets
304 ;; TODO: respond to attempts to open the curio cabinet
307 #:proxy-items '(lobby:porcelain-doll
309 lobby:tea-set lobby:mustard-pot
310 lobby:head-of-elvis lobby:circuitboard-of-evlis
311 lobby:teletype-scroll lobby:orange-cat-phone)
312 #:name "a curio cabinet"
313 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
314 "cabinet of curiosities")
316 (format #f " The curio cabinet is full of all sorts of oddities!
317 Something catches your eye!
318 Ooh, ~a!" (random-choice
319 '("a creepy porcelain doll"
320 "assorted 1950s robots"
321 "an exquisite tea set"
322 "an antique mustard pot"
323 "the pickled head of Elvis"
324 "the pickled circuitboard of EVLIS"
325 "a scroll of teletype paper holding the software Four Freedoms"
326 "a telephone shaped like an orange cartoon cat")))))
328 ('lobby:porcelain-doll
329 <cabinet-item> 'lobby
331 #:name "a creepy porcelain doll"
332 #:desc "It strikes you that while the doll is technically well crafted,
333 it's also the stuff of nightmares."
334 #:goes-by '("porcelain doll" "doll"))
336 <cabinet-item> 'lobby
338 #:name "a set of 1950s robots"
339 #:desc "There's a whole set of these 1950s style robots.
340 They seem to be stamped out of tin, and have various decorations of levers
341 and buttons and springs. Some of them have wind-up knobs on them."
342 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
344 <cabinet-item> 'lobby
347 #:desc "A complete tea set. Some of the cups are chipped.
348 You can imagine yourself joining a tea party using this set, around a
349 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
350 #:goes-by '("tea set" "tea"))
352 <cabinet-item> 'lobby
354 #:name "cups from the tea set"
355 #:desc "They're chipped."
358 <cabinet-item> 'lobby
360 #:name "a mustard pot"
361 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
362 nice design, and it's an antique, but you can't imagine putting something
363 like this in a museum.")
364 (p "Ha... imagine that... a mustard museum."))
365 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
366 ('lobby:head-of-elvis
367 <cabinet-item> 'lobby
369 #:name "the pickled head of Elvis"
370 #:desc '((p "It's a jar full of some briny-looking liquid and...
371 a free floating head. The head looks an awful lot like Elvis, and
372 definitely not the younger Elvis. The hair even somehow maintains
373 that signature swoop while suspended in liquid. But of course it's
375 (p "Oh, wait, it has a label at the bottom which says:
376 \"This is really the head of Elvis\". Well... maybe don't believe
377 everything you read."))
378 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
379 "elvis" "Elvis" "head" "pickled head"))
380 ('lobby:circuitboard-of-evlis
381 <cabinet-item> 'lobby
383 #:name "the pickled circuitboard of Evlis"
384 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
385 This is quite the find, and you bet just about anyone interested in
386 preserving computer history would love to get their hands on this.")
387 (p "Unfortunately, whatever moron did acquire this has
388 no idea what it means to preserve computers, so here it is floating
389 in some kind of briny liquid. It appears to be heavily corroded.
391 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
392 "pickled circuitboard of EVLIS"
393 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
394 ('lobby:teletype-scroll
395 <cabinet-item> 'lobby
397 #:name "a scroll of teletype"
398 #:desc '((p "This is a scroll of teletype paper. It's a bit old
399 and yellowed but the type is very legible. It says:")
402 (p (strong "== The four essential freedoms =="))
403 (p "A program is free software if the program's users have
404 the four essential freedoms: ")
405 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
406 (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.")
407 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
408 (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.")))
409 (p "You get this feeling that ambiguities in the
410 English language surrounding the word 'free' have lead to a lot of terminology debates."))
411 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
412 "teletype paper" "scroll" "four freedoms"
413 "scroll of teletype paper holding the software Four Freedoms"
414 "scroll of teletype paper holding the software four freedoms"))
415 ('lobby:orange-cat-phone
416 <cabinet-item> 'lobby
418 #:name "a telephone shaped like an orange cartoon cat"
419 #:desc "It's made out of a cheap plastic, and it's very orange.
420 It resembles a striped tabby, and it's eyes hold the emotion of
421 a being both sleepy and smarmy.
422 You suspect that someone, somewhere made a ton of cash on items holding
423 this general shape in the 1990s."
424 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
425 "orange cat phone" "orange cat telephone"
426 "cartoon cat phone" "cartoon cat"
427 "cat phone" "cat telephone" "phone" "telephone"))))
434 (define-actor <disc-shield> (<gameobj>)
435 ((cmd-take disc-shield-take)))
437 (define* (disc-shield-take gameobj message
439 (player (message-from message)))
440 (create-gameobj <glowing-disc> (gameobj-gm gameobj)
441 player) ;; set loc to player to put in player's inventory
443 #:text '((p "As you attempt to pull the shield / disk platter
444 from the statue a shining outline appears around it... and a
445 completely separate, glowing copy of the disc materializes into your
447 (<- (gameobj-loc gameobj) 'tell-room
448 #:text `(,(mbody-val (<-wait player 'get-name))
449 " pulls on the shield of the statue, and a glowing "
450 "copy of it materializes into their hands!")
452 (<- (gameobj-loc gameobj) 'tell-room
454 '(p "You hear a voice whisper: "
455 (i "\"Share the software... and you'll be free...\""))))
457 ;;; This is the disc that gets put in the player's inventory
458 (define-actor <glowing-disc> (<gameobj>)
459 ((cmd-drop glowing-disc-drop-cmd))
461 #:allocation #:each-subclass
462 #:init-thunk (build-props
463 '((hd-platter? . #t))))
464 (name #:allocation #:each-subclass
465 #:init-value "a glowing disc")
466 (desc #:allocation #:each-subclass
467 #:init-value "A brightly glowing disc. It's shaped like a hard
468 drive platter, not unlike the one from the statue it came from. It's
469 labeled \"RL02.5\".")
470 (goes-by #:init-value '("glowing disc" "glowing platter"
471 "glowing disc platter" "glowing disk platter"
472 "platter" "disc" "disk" "glowing shield")))
474 (define* (glowing-disc-drop-cmd gameobj message
476 (player (message-from message)))
478 #:text "You drop the glowing disc, and it shatters into a million pieces!")
479 (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
480 #:text `(,(mbody-val (<-wait player 'get-name))
481 " drops a glowing disc, and it shatters into a million pieces!")
483 (gameobj-self-destruct gameobj))
488 (define lobby-map-text
491 .----------.----------. : & : .----------.----------.
492 | computer | |& :YOU ARE: &| smoking | *UNDER* |
493 | room + playroom + : HERE : + parlor | *CONS- |
494 | > | |& : : &| | TRUCTION*|
495 '----------'----------'-++-------++-'-------+--'----------'
501 (define grand-hallway
505 #:name "Grand Hallway"
506 #:desc '((p " A majestic red carpet runs down the center of the room.
507 Busts of serious looking people line the walls, but there's no
508 clear indication that they have any logical relation to this place.")
509 (p "In the center is a large statue of a woman in a warrior's
510 pose, but something is strange about her weapon and shield. You wonder what
512 (p "To the south is the lobby. A door to the east is labeled \"smoking
513 room\", while a door to the west is labeled \"playroom\"."))
523 #:to 'smoking-parlor)))
525 <readable> 'grand-hallway
526 #:name "the hotel map"
527 #:desc '("This appears to be a map of the hotel. "
528 "Like the hotel itself, it seems to be "
530 "You could read it if you want to.")
531 #:read-text `(pre ,lobby-map-text)
532 #:goes-by '("map" "hotel map"))
533 ('grand-hallway:carpet
534 <gameobj> 'grand-hallway
535 #:name "the Grand Hallway carpet"
536 #:desc "It's very red, except in the places where it's very worn."
538 #:goes-by '("red carpet" "carpet"))
539 ('grand-hallway:busts
540 <gameobj> 'grand-hallway
541 #:name "the busts of serious people"
542 #:desc "There are about 6 of them in total. They look distinguished
543 but there's no indication of who they are."
545 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
546 ('grand-hallway:hackthena-statue
547 <proxy-items> 'grand-hallway
548 #:name "the statue of Hackthena"
549 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
550 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
551 all good hacks, and legendary hacker herself.")
552 (p "Hackthena holds the form of a human woman. She wears flowing
553 robes, has a pear of curly bovine-esque horns protruding from the sides of her
554 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
555 But instead of a weapon, she seems to hold some sort of keyboard. And her
556 shield... well it's round like a shield, but something seems off about it.
557 You'd better take a closer look to be sure."))
558 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
559 #:proxy-items '(grand-hallway:keyboard
560 grand-hallway:disc-platter
561 grand-hallway:hackthena-horns))
562 ('grand-hallway:keyboard
563 <gameobj> 'grand-hallway
564 #:name "a Knight Keyboard"
565 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
566 Any space cadet can see that with that kind of layout a hack-and-slayer could
567 thrash out some serious key-chords like there's no tomorrow. You guess
568 Hackthena must be an emacs user."
573 `("Are you kidding? Do you know how hard it is to find "
574 "a Knight Keyboard? There's no way she's going "
575 "to give that up.")))
576 #:goes-by '("knight keyboard" "keyboard"))
577 ('grand-hallway:hackthena-horns
578 <gameobj> 'grand-hallway
579 #:name "Hackthena's horns"
580 #:desc "They're not unlike a Gnu's horns."
585 `("Are you seriously considering desecrating a statue?")))
586 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
587 ('grand-hallway:disc-platter
588 <disc-shield> 'grand-hallway
589 #:name "Hackthena's shield"
590 #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
591 platter! It has \"RL02.5\" written on it. It looks kind of loose."
593 #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
599 (define-actor <rgb-machine> (<gameobj>)
600 ((cmd-run rgb-machine-cmd-run)
601 (cmd-reset rgb-machine-cmd-reset))
603 #:allocation #:each-subclass
604 #:init-thunk (build-commands
605 (("run" "start") ((direct-command cmd-run)))
606 ("reset" ((direct-command cmd-reset)))))
607 (resetting #:init-value #f
608 #:accessor .resetting)
609 ;; used to reset, and to kick off the first item in the list
610 (rgb-items #:init-keyword #:rgb-items
611 #:accessor .rgb-items))
613 (define (rgb-machine-cmd-run rgb-machine message . _)
614 (define player (message-from message))
616 #:text '("You start the rube goldberg machine."))
617 (<-wait (gameobj-loc rgb-machine) 'tell-room
618 #:text `(,(mbody-val (<-wait player 'get-name))
619 " runs the rube goldberg machine.")
622 (match (.rgb-items rgb-machine)
623 ((first-item rest ...)
624 (<- (dyn-ref rgb-machine first-item) 'trigger))))
626 (define (rgb-machine-cmd-reset rgb-machine message . _)
627 (define player (message-from message))
629 ((not (.resetting rgb-machine))
630 (set! (.resetting rgb-machine) #t)
632 #:text '("You reset the rube goldberg machine."))
633 (<-wait (gameobj-loc rgb-machine) 'tell-room
634 #:text `(,(mbody-val (<-wait player 'get-name))
635 " resets the rube goldberg machine.")
637 (<-wait (gameobj-loc rgb-machine) 'tell-room
638 #:text '("From a panel in the wall, a white gloved mechanical "
639 "arm reaches out to reset all the "
640 "rube goldberg components."))
644 (<- (dyn-ref rgb-machine rgb-item) 'reset)
646 (.rgb-items rgb-machine))
647 (<- (gameobj-loc rgb-machine) 'tell-room
648 #:text "The machine's mechanical arm retreats into the wall!")
649 (set! (.resetting rgb-machine) #f))
652 #:text '("But it's in the middle of resetting right now!")))))
654 (define-actor <rgb-item> (<gameobj>)
655 ((trigger rgb-item-trigger)
656 (reset rgb-item-reset))
657 (invisible? #:init-value #t)
658 (steps #:init-keyword #:steps
660 (triggers-as #:init-value #f
661 #:init-keyword #:triggers-as
662 #:getter .triggers-as)
663 (reset-msg #:init-keyword #:reset-msg
665 ;; States: ready -> running -> ran
666 (state #:init-value 'ready
670 (define (rgb-item-trigger rgb-item message . _)
671 (define room (gameobj-loc rgb-item))
672 (case (.state rgb-item)
674 ;; Set state to running
675 (set! (.state rgb-item) 'running)
677 ;; Loop through all steps
681 ;; A string? That's the description of what's happening, tell players
683 (<- room 'tell-room #:text str))
684 ;; A number? Sleep for that many secs
687 ;; A symbol? That's another gameobj to look up dynamically
689 (<- (dyn-ref rgb-item sym) 'trigger
690 #:triggered-by (.triggers-as rgb-item)))
691 (_ (throw 'unknown-step-type
692 "Don't know how to process rube goldberg machine step type?"
696 ;; We're done! Set state to ran
697 (set! (.state rgb-item) 'ran))
701 #:text `("... but " ,(slot-ref rgb-item 'name)
702 " has already been triggered!")))))
704 (define (rgb-item-reset rgb-item message . _)
705 (define room (gameobj-loc rgb-item))
706 (case (.state rgb-item)
708 (set! (.state rgb-item) 'ready)
710 #:text (.reset-msg rgb-item)))
713 #:text `("... but " ,(slot-ref rgb-item 'name)
714 " is currently running!")))
717 #:text `("... but " ,(slot-ref rgb-item 'name)
718 " has already been reset.")))))
720 (define-actor <rgb-kettle> (<rgb-item>)
721 ((trigger rgb-kettle-trigger)
722 (reset rgb-kettle-reset))
723 (heated #:accessor .heated
725 (filled #:accessor .filled
728 (define* (rgb-kettle-trigger rgb-item message #:key triggered-by)
729 (define room (gameobj-loc rgb-item))
730 (if (not (eq? (.state rgb-item) 'ran))
734 (set! (.state rgb-item) 'running)
735 (set! (.filled rgb-item) #t))
737 (set! (.state rgb-item) 'running)
738 (set! (.heated rgb-item) #t)))
739 (when (and (.filled rgb-item)
742 #:text '((i "*kshhhhhh!*")
743 " The water has boiled!"))
745 (set! (.state rgb-item) 'ran)
746 ;; insert a cup of hot tea in the room
747 (create-gameobj <hot-tea> (gameobj-gm rgb-item) room)
749 #:text '("The machine pours out a cup of hot tea! "
750 "Looks like the machine finished!"))))
752 #:text `("... but " ,(slot-ref rgb-item 'name)
753 " has already been triggered!"))))
755 (define (rgb-kettle-reset rgb-item message . rest-args)
756 (define room (gameobj-loc rgb-item))
757 (when (eq? (.state rgb-item) 'ran)
758 (set! (.heated rgb-item) #f)
759 (set! (.filled rgb-item) #f))
760 (apply rgb-item-reset rgb-item message rest-args))
762 (define-actor <tinfoil-hat> (<gameobj>)
763 ((cmd-wear tinfoil-hat-wear))
765 #:allocation #:each-subclass
766 #:init-thunk (build-commands
767 ("wear" ((direct-command cmd-wear))))))
769 (define (tinfoil-hat-wear tinfoil-hat message . _)
770 (<- (message-from message) 'tell
771 #:text '("You put on the tinfoil hat, and, to be perfectly honest with you "
772 "it's a lot harder to take you seriously.")))
775 (define-actor <hot-tea> (<gameobj>)
776 ((cmd-drink hot-tea-cmd-drink)
777 (cmd-sip hot-tea-cmd-sip))
779 #:allocation #:each-subclass
780 #:init-thunk (build-commands
781 ("drink" ((direct-command cmd-drink)))
782 ("sip" ((direct-command cmd-sip)))))
784 (sips-left #:init-value 4
785 #:accessor .sips-left)
786 (name #:init-value "a cup of hot tea")
787 (take-me? #:init-value #t)
788 (goes-by #:init-value '("cup of hot tea" "cup of tea" "tea" "cup"))
789 (desc #:init-value "It's a steaming cup of hot tea. It looks pretty good!"))
791 (define (hot-tea-cmd-drink hot-tea message . _)
792 (define player (message-from message))
793 (define player-loc (mbody-val (<-wait player 'get-loc)))
794 (define player-name (mbody-val (<-wait player 'get-name)))
796 #:text "You drink a steaming cup of hot tea all at once... hot hot hot!")
797 (<- player-loc 'tell-room
798 #:text `(,player-name
799 " drinks a steaming cup of hot tea all at once.")
801 (gameobj-self-destruct hot-tea))
803 (define (hot-tea-cmd-sip hot-tea message . _)
804 (define player (message-from message))
805 (define player-loc (mbody-val (<-wait player 'get-loc)))
806 (define player-name (mbody-val (<-wait player 'get-name)))
807 (set! (.sips-left hot-tea) (- (.sips-left hot-tea) 1))
809 #:text "You take a sip of your steaming hot tea. How refined!")
810 (<- player-loc 'tell-room
811 #:text `(,player-name
812 " takes a sip of their steaming hot tea. How refined!")
814 (when (= (.sips-left hot-tea) 0)
816 #:text "You've finished your tea!")
817 (<- player-loc 'tell-room
818 #:text `(,player-name
819 " finishes their tea!")
821 (gameobj-self-destruct hot-tea)))
823 (define-actor <fanny-pack> (<container>)
824 ((cmd-take-from-while-wearing cmd-take-from)
825 (cmd-put-in-while-wearing cmd-put-in))
827 #:allocation #:each-subclass
830 (("l" "look") ((direct-command cmd-look-at)))
831 ("take" ((prep-indir-command cmd-take-from-while-wearing
832 '("from" "out of"))))
833 ("put" ((prep-indir-command cmd-put-in-while-wearing
834 '("in" "inside" "into" "on")))))))
840 #:name "The Playroom"
841 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
842 if this room is intended for children or child-like adults.")
843 (" There are doors to both the east and the west."))
850 #:to 'computer-room)))
855 #:desc " It's a little foam cube with googly eyes on it. So cute!")
856 ('playroom:cuddles-plushie
858 #:name "a Cuddles plushie"
859 #:goes-by '("plushie" "cuddles plushie" "cuddles")
861 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
864 <container> 'playroom
866 #:goes-by '("toy chest" "chest")
867 #:desc (lambda (toy-chest whos-looking)
868 (let ((contents (gameobj-occupants toy-chest)))
869 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
872 ,(if (eq? contents '())
873 " nothing! It's empty!"
874 `(ul ,(map (lambda (occupant)
876 (<-wait occupant 'get-name))))
877 (gameobj-occupants toy-chest))))))))
881 ;; Things inside the toy chest
882 ('playroom:toy-chest:rubber-duck
883 <gameobj> 'playroom:toy-chest
884 #:name "a rubber duck"
885 #:goes-by '("rubber duck" "duck")
887 #:desc "It's a yellow rubber duck with a bright orange beak.")
889 ('playroom:toy-chest:tinfoil-hat
890 <tinfoil-hat> 'playroom:toy-chest
891 #:name "a tinfoil hat"
892 #:goes-by '("tinfoil hat" "hat")
894 #:desc "You'd have to be a crazy person to wear this thing!")
896 ('playroom:toy-chest:fanny-pack
897 <fanny-pack> 'playroom:toy-chest
898 #:name "a fanny pack"
899 #:goes-by '("fanny pack" "pack")
902 (lambda (toy-chest whos-looking)
903 (let ((contents (gameobj-occupants toy-chest)))
904 `((p "It's a leather fanny pack, so it's both tacky and kinda cool.")
906 ,(if (eq? contents '())
907 " nothing! It's empty!"
908 `(ul ,(map (lambda (occupant)
910 (<-wait occupant 'get-name))))
911 (gameobj-occupants toy-chest)))))))))
913 ;; Things inside the toy chest
914 ('playroom:toy-chest:fanny-pack:plastic-elephant
915 <gameobj> 'playroom:toy-chest:fanny-pack
916 #:name "a plastic elephant"
917 #:goes-by '("plastic elephant" "elephant")
919 #:desc "It's a tiny little plastic elephant. Small, but heartwarming.")
921 ('playroom:rgb-machine
922 <rgb-machine> 'playroom
923 #:name "a Rube Goldberg machine"
924 #:goes-by '("rube goldberg machine" "machine")
925 #:rgb-items '(playroom:rgb-dominoes
926 playroom:rgb-switch-match
928 playroom:rgb-catapult
929 playroom:rgb-water-demon
930 playroom:rgb-quik-heater
932 #:desc "It's one of those hilarious Rube Goldberg machines.
933 What could happen if you started it?")
936 ('playroom:rgb-dominoes
938 #:name "some dominoes"
939 #:goes-by '("dominoes" "some dominoes")
940 #:steps `("The dominoes topple down the line..."
942 "The last domino lands on a switch!"
944 playroom:rgb-switch-match)
945 #:reset-msg "The dominoes are placed back into position.")
947 ;; Which hit the switch and strike a match
948 ('playroom:rgb-switch-match
951 #:goes-by '("switch" "match")
952 #:steps `("The switch lights a match!"
954 "The match lights a candle!"
957 #:reset-msg "A fresh match is installed and the switch is reset.")
958 ;; which lights a candle and burns a rope
959 ('playroom:rgb-candle
962 #:goes-by '("candle")
963 #:steps `("The candle burns..."
965 "The candle is burning away a rope!"
969 playroom:rgb-catapult)
970 #:reset-msg "A fresh candle is installed.")
971 ;; which catapults a rock
972 ('playroom:rgb-catapult
975 #:goes-by '("catapult")
976 #:steps `("The snapped rope unleashes a catapult, which throws a rock!"
978 "The rock flies through a water demon, startling it!"
980 playroom:rgb-water-demon
982 "The rock whacks into the quik-heater's on button!"
984 playroom:rgb-quik-heater)
986 '("A fresh rope is attached to the catapult, which is pulled taught. "
987 "A fresh rock is placed on the catapult."))
989 ;; '- panics the water demon
990 ;; '- which waters the kettle
991 ('playroom:rgb-water-demon
993 #:name "the water demon"
994 #:triggers-as 'water-demon
995 #:goes-by '("water demon" "demon")
996 #:steps `("The water demon panics, and starts leaking water into the kettle below!"
998 "The kettle is filled!"
1000 #:reset-msg '("The water demon is scratched behind the ears and calms down."))
1001 ;; '- bops the quik-heater button
1002 ;; '- which heats the kettle
1003 ('playroom:rgb-quik-heater
1004 <rgb-item> 'playroom
1005 #:name "the quik heater"
1006 #:triggers-as 'quik-heater
1007 #:goes-by '("quik heater" "heater")
1008 #:steps `("The quik-heater heats up the kettle above it!"
1010 "The kettle is heated up!"
1011 playroom:rgb-kettle)
1012 #:reset-msg '("The quik heater is turned off."))
1013 ;; Finally, the kettle
1014 ('playroom:rgb-kettle
1015 <rgb-kettle> 'playroom
1017 #:goes-by '("kettle")
1018 #:reset-msg '("The kettle is emptied."))))
1029 ;; ... full of NURPH weapons?
1035 (define-class <furniture> (<gameobj>)
1036 (sit-phrase #:init-keyword #:sit-phrase)
1037 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
1038 (sit-name #:init-keyword #:sit-name)
1041 #:allocation #:each-subclass
1042 #:init-thunk (build-commands
1043 ("sit" ((direct-command cmd-sit-furniture)))))
1044 (actions #:allocation #:each-subclass
1045 #:init-thunk (build-actions
1046 (cmd-sit-furniture furniture-cmd-sit))))
1048 (define* (furniture-cmd-sit actor message #:key direct-obj)
1050 (mbody-val (<-wait (message-from message) 'get-name)))
1051 (<- (message-from message) 'tell
1052 #:text (format #f "You ~a ~a.\n"
1053 (slot-ref actor 'sit-phrase)
1054 (slot-ref actor 'sit-name)))
1055 (<- (slot-ref actor 'loc) 'tell-room
1056 #:text (format #f "~a ~a on ~a.\n"
1058 (slot-ref actor 'sit-phrase-third-person)
1059 (slot-ref actor 'sit-name))
1060 #:exclude (message-from message)))
1063 (define smoking-parlor
1067 #:name "Smoking Parlor"
1069 '((p "This room looks quite posh. There are huge comfy seats you can sit in
1070 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
1071 have installed this place and then changed their mind later.")
1072 (p "There's a door to the west leading back to the grand hallway, and
1073 a nondescript steel door to the south, leading apparently outside."))
1077 #:to 'grand-hallway)
1081 ('smoking-parlor:chair
1082 <furniture> 'smoking-parlor
1083 #:name "a comfy leather chair"
1084 #:desc " That leather chair looks really comfy!"
1085 #:goes-by '("leather chair" "comfy leather chair" "chair")
1086 #:sit-phrase "sink into"
1087 #:sit-phrase-third-person "sinks into"
1088 #:sit-name "the comfy leather chair")
1089 ('smoking-parlor:sofa
1090 <furniture> 'smoking-parlor
1091 #:name "a plush leather sofa"
1092 #:desc " That leather chair looks really comfy!"
1093 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
1094 "leather couch" "plush leather couch" "couch")
1095 #:sit-phrase "sprawl out on"
1096 #:sit-phrase-third-person "sprawls out on into"
1097 #:sit-name "the plush leather couch")
1098 ('smoking-parlor:bar-stool
1099 <furniture> 'smoking-parlor
1100 #:name "a bar stool"
1101 #:desc " Conveniently located near the bar! Not the most comfortable
1102 seat in the room, though."
1103 #:goes-by '("stool" "bar stool" "seat")
1104 #:sit-phrase "hop on"
1105 #:sit-phrase-third-person "hops onto"
1106 #:sit-name "the bar stool")
1108 <chatty-npc> 'smoking-parlor
1109 #:name "Ford Prefect"
1110 #:desc "Just some guy, you know?"
1111 #:goes-by '("Ford Prefect" "ford prefect"
1112 "frood" "prefect" "ford")
1113 #:catchphrases prefect-quotes)
1115 ('smoking-parlor:no-smoking-sign
1116 <readable> 'smoking-parlor
1118 #:name "No Smoking Sign"
1119 #:desc "This sign says \"No Smoking\" in big, red letters.
1120 It has some bits of bubble gum stuck to it... yuck."
1121 #:goes-by '("no smoking sign" "sign")
1122 #:read-text "It says \"No Smoking\", just like you'd expect from
1123 a No Smoking sign.")
1124 ;; TODO: Cigar dispenser
1132 (define-class <desk-clerk> (<gameobj>)
1133 ;; The desk clerk has three states:
1134 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
1136 ;; - slacking: In the break room, probably smoking a cigarette
1137 ;; or checking text messages
1138 (state #:init-value 'slacking)
1139 (commands #:allocation #:each-subclass
1142 (("talk" "chat") ((direct-command cmd-chat)))
1143 ("ask" ((direct-command cmd-ask-incomplete)
1144 (prep-direct-command cmd-ask-about)))
1145 ("dismiss" ((direct-command cmd-dismiss)))))
1146 (patience #:init-value 0)
1147 (actions #:allocation #:each-subclass
1148 #:init-thunk (build-actions
1149 (init clerk-act-init)
1150 (cmd-chat clerk-cmd-chat)
1151 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
1152 (cmd-ask-about clerk-cmd-ask)
1153 (cmd-dismiss clerk-cmd-dismiss)
1154 (update-loop clerk-act-update-loop)
1155 (be-summoned clerk-act-be-summoned))))
1157 (define (clerk-act-init clerk message . _)
1158 ;; call the gameobj main init method
1159 (gameobj-act-init clerk message)
1160 ;; start our main loop
1161 (<- (actor-id clerk) 'update-loop))
1163 (define changing-name-text "Changing your name is easy!
1164 We have a clipboard here at the desk
1165 where you can make yourself known to other participants in the hotel
1166 if you sign it. Try 'sign form as <your-name>', replacing
1167 <your-name>, obviously!")
1170 "Ah... when I'm not here, I've got a PHD to finish.")
1172 (define clerk-help-topics
1173 `(("changing name" . ,changing-name-text)
1174 ("sign-in form" . ,changing-name-text)
1175 ("form" . ,changing-name-text)
1176 ("common commands" .
1177 "Here are some useful commands you might like to try: chat,
1178 go, take, drop, say...")
1180 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
1181 our hotel emphasizes interesting experiences over rest and lodging.
1182 The origins of the hotel are... unclear... and it has recently come
1183 under new... 'management'. But at Hotel Bricabrac we believe these
1184 aspects make the hotel into a fun and unique experience! Please,
1185 feel free to walk around and explore.")
1186 ("physics paper" . ,phd-text)
1187 ("paper" . ,phd-text)
1188 ("proprietor" . "Oh, he's that frumpy looking fellow sitting over there.")))
1191 (define clerk-knows-about
1192 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
1194 (define clerk-general-helpful-line
1196 "The clerk says, \"If you need help with anything, feel free to ask me about it.
1197 For example, 'ask clerk about changing name'. You can ask me about the following:
1198 " clerk-knows-about ".\"\n"))
1200 (define clerk-slacking-complaints
1201 '("The pay here is absolutely lousy."
1202 "The owner here has no idea what they're doing."
1203 "Some times you just gotta step away, you know?"
1204 "You as exhausted as I am?"
1205 "Yeah well, this is just temporary. I'm studying to be a high
1206 energy particle physicist. But ya gotta pay the bills, especially
1207 with tuition at where it is..."))
1209 (define* (clerk-cmd-chat clerk message #:key direct-obj)
1210 (match (slot-ref clerk 'state)
1212 (<- (message-from message) 'tell
1213 #:text clerk-general-helpful-line))
1215 (<- (message-from message) 'tell
1218 "The clerk says, \""
1219 (random-choice clerk-slacking-complaints)
1222 (define (clerk-cmd-ask-incomplete clerk message . _)
1223 (<- (message-from message) 'tell
1224 #:text "The clerk says, \"Ask about what?\"\n"))
1226 (define clerk-doesnt-know-text
1227 "The clerk apologizes and says she doesn't know about that topic.\n")
1229 (define* (clerk-cmd-ask clerk message #:key indir-obj
1231 (match (slot-ref clerk 'state)
1233 (match (assoc indir-obj clerk-help-topics)
1235 (<- (message-from message) 'tell
1237 (string-append "The clerk clears her throat and says:\n \""
1241 (<- (message-from message) 'tell
1242 #:text clerk-doesnt-know-text))))
1244 (<- (message-from message) 'tell
1245 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
1247 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
1248 (match (slot-ref clerk 'state)
1250 (<- who-summoned 'tell
1252 "The clerk tells you as politely as she can that she's already here,
1253 so there's no need to ring the bell.\n"))
1255 (<- (gameobj-loc clerk) 'tell-room
1257 "The clerk's ears perk up, she stamps out a cigarette, and she
1258 runs out of the room!\n")
1259 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
1260 (slot-set! clerk 'patience 8)
1261 (slot-set! clerk 'state 'on-duty)
1262 (<- (gameobj-loc clerk) 'tell-room
1265 " Suddenly, a uniformed woman rushes into the room! She's wearing a
1266 badge that says \"Desk Clerk\".
1267 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
1268 We look forward to your stay. If you'd like help getting acclimated,
1269 feel free to ask me. For example, 'ask clerk about changing name'.
1270 You can ask me about the following:
1271 " clerk-knows-about ".\"\n")))))
1273 (define* (clerk-cmd-dismiss clerk message . _)
1275 (mbody-val (<-wait (message-from message) 'get-name)))
1276 (match (slot-ref clerk 'state)
1278 (<- (gameobj-loc clerk) 'tell-room
1280 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
1281 The clerk leaves the room in a hurry.\n"
1283 #:exclude (actor-id clerk))
1284 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
1285 (slot-set! clerk 'state 'slacking)
1286 (<- (gameobj-loc clerk) 'tell-room
1287 #:text clerk-return-to-slacking-text
1288 #:exclude (actor-id clerk)))
1290 (<- (message-from message) 'tell
1291 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
1293 (define clerk-slacking-texts
1294 '("The clerk takes a long drag on her cigarette.\n"
1295 "The clerk scrolls through text messages on her phone.\n"
1296 "The clerk coughs a few times.\n"
1297 "The clerk checks her watch and justifies a few more minutes outside.\n"
1298 "The clerk fumbles around for a lighter.\n"
1299 "The clerk sighs deeply and exhaustedly.\n"
1300 "The clerk fumbles around for a cigarette.\n"))
1302 (define clerk-working-impatience-texts
1303 '("The clerk hums something, but you're not sure what it is."
1304 "The clerk attempts to change the overhead music, but the dial seems broken."
1305 "The clerk clicks around on the desk computer."
1306 "The clerk scribbles an equation on a memo pad, then crosses it out."
1307 "The clerk mutters something about the proprietor having no idea how to run a hotel."
1308 "The clerk thumbs through a printout of some physics paper."))
1310 (define clerk-slack-excuse-text
1311 "The desk clerk excuses herself, but says you are welcome to ring the bell
1312 if you need further help.")
1314 (define clerk-return-to-slacking-text
1315 "The desk clerk enters and slams the door behind her.\n")
1318 (define (clerk-act-update-loop clerk message)
1319 (define (tell-room text)
1320 (<- (gameobj-loc clerk) 'tell-room
1322 #:exclude (actor-id clerk)))
1323 (define (loop-if-not-destructed)
1324 (if (not (slot-ref clerk 'destructed))
1325 ;; This iterates by "recursing" on itself by calling itself
1326 ;; (as the message handler) again. It used to be that we had to do
1327 ;; this, because there was a bug where a loop which yielded like this
1328 ;; would keep growing the stack due to some parameter goofiness.
1329 ;; That's no longer true, but there's an added advantage to this
1330 ;; route: it's much more live hackable. If we change the definition
1331 ;; of this method, the character will act differently on the next
1332 ;; "tick" of the loop.
1333 (<- (actor-id clerk) 'update-loop)))
1334 (match (slot-ref clerk 'state)
1336 (tell-room (random-choice clerk-slacking-texts))
1337 (8sleep (+ (random 20) 15))
1338 (loop-if-not-destructed))
1340 (if (> (slot-ref clerk 'patience) 0)
1341 ;; Keep working but lose patience gradually
1343 (tell-room (random-choice clerk-working-impatience-texts))
1344 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
1346 (8sleep (+ (random 60) 40))
1347 (loop-if-not-destructed))
1350 (tell-room clerk-slack-excuse-text)
1351 ;; back bto the break room
1352 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
1353 (tell-room clerk-return-to-slacking-text)
1354 ;; annnnnd back to slacking
1355 (slot-set! clerk 'state 'slacking)
1356 (8sleep (+ (random 30) 15))
1357 (loop-if-not-destructed))))))
1364 #:name "Employee Break Room"
1365 #:desc " This is less a room and more of an outdoor wire cage. You get
1366 a bit of a view of the brick exterior of the building, and a crisp wind blows,
1367 whistling, through the openings of the fenced area. Partly smoked cigarettes
1368 and various other debris cover the floor.
1369 Through the wires you can see... well... hm. It looks oddly like
1370 the scenery tapers off nothingness. But that can't be right, can it?"
1374 #:to 'smoking-parlor)))
1375 ('break-room:desk-clerk
1376 <desk-clerk> 'break-room
1377 #:name "the hotel desk clerk"
1378 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
1379 hotel insignia. She appears to be rather exhausted."
1380 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
1382 <gameobj> 'break-room
1385 #:desc "As you stare into the void, the void stares back into you."
1386 #:goes-by '("void" "abyss" "nothingness" "scenery"))
1388 <gameobj> 'break-room
1390 #:name "break room cage"
1391 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
1392 You can see through the gaps, but they're too small to put more than a
1393 couple of fingers through. There appears to be some wear and tear to
1394 the paint, but the wires themselves seem to be unusually sturdy."
1395 #:goes-by '("fence" "cage" "wire cage"))))
1399 ;;; Ennpie's Sea Lounge
1400 ;;; -------------------
1406 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
1407 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
1408 ;; to distinguish both from the real thing.
1410 (define-actor <hard-drive> (<gameobj>)
1411 ((cmd-put-in hard-drive-insert)
1412 (cmd-push-button hard-drive-push-button)
1413 (get-state hard-drive-act-get-state))
1414 (commands #:allocation #:each-subclass
1415 #:init-thunk (build-commands
1416 ("insert" ((prep-indir-command cmd-put-in
1417 '("in" "inside" "into"))))
1418 (("press" "push") ((prep-indir-command cmd-push-button)))))
1419 ;; the state moves from: empty -> with-disc -> loading -> ready
1420 (state #:init-value 'empty
1423 (define (hard-drive-act-get-state hard-drive message)
1424 (<-reply message (.state hard-drive)))
1426 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1427 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
1428 (p "There is a slot where a disk platter could be inserted, "
1429 ,(if (eq? (.state hard-drive) 'empty)
1430 "which is currently empty"
1431 "which contains a glowing platter")
1432 ". There is a LOAD button "
1433 ,(if (member (.state hard-drive) '(empty with-disc))
1435 "which is pressed in and unlit")
1436 ". There is a READY indicator "
1437 ,(if (eq? (.state hard-drive) 'ready)
1440 ,(if (member (.state hard-drive) '(loading ready))
1441 " The machine emits a gentle whirring noise."
1444 (define* (hard-drive-push-button gameobj message
1445 #:key direct-obj indir-obj preposition
1446 (player (message-from message)))
1447 (define (tell-room text)
1448 (<-wait (gameobj-loc gameobj) 'tell-room
1450 (define (tell-room-excluding-player text)
1451 (<-wait (gameobj-loc gameobj) 'tell-room
1455 ((ci-member direct-obj '("button" "load button" "load"))
1456 (tell-room-excluding-player
1457 `(,(mbody-val (<-wait player 'get-name))
1458 " presses the button on the hard disk."))
1460 #:text "You press the button on the hard disk.")
1462 (case (.state gameobj)
1464 ;; I have no idea what this drive did when you didn't have a platter
1465 ;; in it and pressed load, but I know there was a FAULT button.
1466 (tell-room "You hear some movement inside the hard drive...")
1469 '("... but then the FAULT button blinks a couple times. "
1470 "What could be missing?")))
1472 (set! (.state gameobj) 'loading)
1473 (tell-room "The hard disk begins to spin up!")
1475 (set! (.state gameobj) 'ready)
1476 (tell-room "The READY light turns on!"))
1479 #:text '("Pressing the button does nothing right now, "
1480 "but it does feel satisfying.")))))
1483 #:text '("How could you think of pressing anything else "
1484 "but that tantalizing button right in front of you?")))))
1486 (define* (hard-drive-insert gameobj message
1487 #:key direct-obj indir-obj preposition
1488 (player (message-from message)))
1489 (define our-name (slot-ref gameobj 'name))
1493 (for-each (lambda (occupant)
1494 (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1495 (when (ci-member direct-obj goes-by)
1497 (mbody-val (<-wait player 'get-occupants)))
1503 #:text `("You don't seem to have any such " ,direct-obj " to put "
1504 ,preposition " " ,our-name ".")))
1505 ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1507 #:text `("It wouldn't make sense to put "
1508 ,(mbody-val (<-wait this-thing 'get-name))
1509 " " ,preposition " " ,our-name ".")))
1510 ((not (eq? (.state gameobj) 'empty))
1512 #:text "The disk drive already has a platter in it."))
1514 (set! (.state gameobj) 'with-disc)
1516 #:text '((p "You insert the glowing disc into the drive.")
1517 (p "The LOAD button begins to glow."))))))
1520 (define-actor <computer> (<gameobj>)
1521 ((cmd-run-program computer-run-program)
1522 (cmd-run-what (lambda (gameobj message . _)
1523 (<- (message-from message) 'tell
1524 #:text '("The computer is already running, and a program appears "
1526 "you mean to \"run the program on the computer\""))))
1527 (cmd-help-run-not-press
1528 (lambda (gameobj message . _)
1529 (<- (message-from message) 'tell
1530 #:text '("You don't need to press / push / flip anything. "
1531 "You could " (i "run program on computer")
1532 " already if you wanted to.")))))
1533 (commands #:allocation #:each-subclass
1534 #:init-thunk (build-commands
1535 ("run" ((prep-indir-command cmd-run-program
1537 (direct-command cmd-run-what)))
1538 (("press" "push" "flip")
1539 ((prep-indir-command cmd-help-run-not-press))))))
1541 (define* (computer-run-program gameobj message
1542 #:key direct-obj indir-obj preposition
1543 (player (message-from message)))
1545 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
1546 (define (tell-room text)
1547 (<-wait (gameobj-loc gameobj) 'tell-room
1549 (define (tell-room-excluding-player text)
1550 (<-wait (gameobj-loc gameobj) 'tell-room
1553 (define (tell-player text)
1554 (<-wait player 'tell
1557 ((ci-member direct-obj '("program"))
1558 (tell-room-excluding-player
1559 `(,(mbody-val (<-wait player 'get-name))
1560 " runs the program loaded on the computer..."))
1561 (tell-player "You run the program on the computer...")
1564 ((not (eq? (hd-state) 'ready))
1565 (tell-room '("... but it errors out. "
1566 "It seems to be complaining about a " (b "DISK ERROR!")
1567 ". It looks like it is missing some essential software.")))
1569 (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
1573 (define-actor <floor-panel> (<gameobj>)
1574 ;; TODO: Add "open" verb, since obviously people will try that
1575 ((open? (lambda (panel message)
1576 (<-reply message (slot-ref panel 'open))))
1577 (open-up floor-panel-open-up))
1578 (open #:init-value #f))
1580 (define (floor-panel-open-up panel message)
1581 (if (slot-ref panel 'open)
1582 (<- (gameobj-loc panel) 'tell-room
1583 #:text '("You hear some gears grind around the hinges of the "
1584 "floor panel, but it appears to already be open."))
1586 (slot-set! panel 'open #t)
1587 (<- (gameobj-loc panel) 'tell-room
1588 #:text '("You hear some gears grind, as the metal panel on "
1589 "the ground opens and reveals a stairwell going down!")))))
1591 (define* (floor-panel-desc panel #:optional whos-looking)
1592 `("It's a large metal panel on the floor in the middle of the room. "
1593 ,(if (slot-ref panel 'open)
1594 '("It's currently wide open, revealing a spiraling staircase "
1595 "which descends into darkness.")
1596 '("It's currently closed shut, but there are clearly hinges, and "
1597 "it seems like there is a mechanism which probably opens it via "
1598 "some automation. What could be down there?"))))
1600 (define computer-room
1604 #:name "Computer Room"
1605 #:desc (lambda (gameobj whos-looking)
1607 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
1609 `((p "A sizable computer cabinet covers a good portion of the left
1610 wall. It emits a pleasant hum which covers the room like a warm blanket.
1611 Connected to a computer is a large hard drive.")
1612 (p "On the floor is a large steel panel. "
1614 '("It is wide open, exposing a spiral staircase "
1615 "which descends into darkness.")
1616 '("It is closed, but it has hinges which "
1617 "suggest it could be opened.")))))
1624 #:to 'underground-lab
1626 (lambda (exit room whos-exiting)
1628 (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
1631 (values #t "You descend the spiral staircase.")
1632 (values #f '("You'd love to go down, but the only way "
1633 "through is through that metal panel, "
1634 "which seems closed.")))))))
1635 ('computer-room:hard-drive
1636 <hard-drive> 'computer-room
1637 #:name "the hard drive"
1638 #:desc (wrap-apply hard-drive-desc)
1639 #:goes-by '("hard drive" "drive" "hard disk"))
1640 ('computer-room:computer
1641 <computer> 'computer-room
1642 #:name "the computer"
1643 #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
1644 (p "The computer is itself turned on, and it looks like it is "
1645 "all set up for you to run a program on it."))
1646 #:goes-by '("computer"))
1647 ('computer-room:floor-panel
1648 <floor-panel> 'computer-room
1649 #:name "a floor panel"
1650 #:desc (wrap-apply floor-panel-desc)
1652 #:goes-by '("floor panel" "panel"))))
1655 ;;; * UNDERGROUND SECTION OF THE GAME! *
1660 (define underground-map-text
1665 | [8sync Hive] |======' '-_____
1671 .--------------. \\ /
1672 | [Guile Async | .-------+------.
1673 | Museum] | | [Lab] #!#| .-------------.
1674 | @| | MM | |[Federation |
1675 | & ^ +##+@ || < +##| Station]|
1677 | & # | |*You-Are-Here*| '-------------'
1678 | # ^ | #+-------+------'
1679 '-------+------' # #
1683 |@?+%? +#### | ^ f## |
1689 (define 8sync-design-goals
1690 '(ul (li (b "Actor based, shared nothing environment: ")
1691 "Shared resources are hard to control and result in fighting
1692 deadlocks, etc. Escape the drudgery: only one actor controls a resource,
1693 and they only receive one message at a time (though they can \"juggle\"
1695 (li (b "Live hackable: ")
1696 "It's hard to plan out a concurrent system; the right structure
1697 is often found by evolving the system while it runs. Make it easy to
1698 build, shape, and change a running system, as well as observe and correct
1700 (li (b "No callback hell: ")
1701 "Just because you're calling out to some other asynchronous
1702 code doesn't mean you should need to chop up your program into a bunch of bits.
1703 Clever use of delimited continuations makes it easy.")))
1705 (define underground-lab
1709 #:name "Underground laboratory"
1710 #:desc '((p "This appears to be some sort of underground laboratory."
1711 "There is a spiral staircase here leading upwards, where "
1712 "it seems much brighter.")
1713 (p "There are a number of doors leading in different directions:
1714 north, south, east, and west, as well as a revolving door to the southwest.
1715 It looks like it could be easy to get lost, but luckily there
1716 is a map detailing the layout of the underground structure."))
1722 (lambda (exit room whos-exiting)
1723 (values #t "You climb the spiral staircase.")))
1728 (lambda (exit room whos-exiting)
1729 (values #t '("You head west through a fancy-looking entrance. "
1730 "A security guard steps aside for you to pass through, "
1731 "into the room, then stands in front of the door."))))
1734 #:to 'hive-entrance)
1737 #:to 'federation-station)
1741 (lambda (exit room whos-exiting)
1742 (values #f '("Ooh, if only you could go south and check this out! "
1743 "Unfortunately this whole area is sealed off... the proprietor "
1744 "probably never got around to fixing it. "
1745 "Too bad, it would have had monsters to fight and everything!"))))
1749 (lambda (exit room whos-exiting)
1750 (values #f '("Hm, it's one of those revolving doors that only revolves in "
1751 "one direction, and it isn't this one. You guess that while "
1752 "this doesn't appear to be an entrance, it probably is an exit."))))))
1754 ('underground-lab:map
1755 <readable> 'underground-lab
1756 #:name "the underground map"
1757 #:desc '("This appears to be a map of the surrounding area. "
1758 "You could read it if you want to.")
1759 #:read-text `(pre ,underground-map-text)
1760 #:goes-by '("map" "underground map" "lab map"))
1762 ('underground-lab:8sync-sign
1763 <readable> 'underground-lab
1764 #:name "a sign labeled \"8sync design goals\""
1765 #:goes-by '("sign" "8sync design goals sign" "8sync goals" "8sync design" "8sync sign")
1766 #:read-text 8sync-design-goals
1767 #:desc `((p "The sign says:")
1768 ,8sync-design-goals))))
1771 ;;; guile async museum
1773 (define async-museum
1778 #:name "Guile Asynchronous Museum"
1779 #:desc '((p "You're in the Guile Asynchronous Museum. There is a list of exhibits
1780 on the wall near the entrance. Scattered around the room are the exhibits
1781 themselves, but it's difficult to pick them out. Maybe you should read the list
1782 to orient yourself.")
1783 (p "There is a door to the east, watched by a security guard,
1784 as well as an exit leading to the south."))
1791 #:to 'underground-lab
1793 (lambda (exit room whos-exiting)
1794 (values #f '("The security guard stops you and tells you "
1795 "that the only exit is through the gift shop."))))))
1797 'async-museum:security-guard
1798 <chatty-npc> 'async-museum
1799 #:name "a security guard"
1801 '(p "The security guard is blocking the eastern entrance, where "
1802 "you came in from.")
1803 #:goes-by '("security guard" "guard" "security")
1804 #:catchphrases '("It's hard standing here all day."
1805 "I just want to go home."
1806 "The exhibits are nice, but I've seen them all before."))
1808 `((p "Welcome to our humble museum! The exhibits are listed below. "
1810 "To look at one, simply type: " (i "look at <exhibit-name>"))
1811 (p "Available exhibits:")
1812 (ul ,@(map (lambda (exhibit)
1817 "The Actor Model"))))))
1819 'async-museum:list-of-exhibits
1820 <readable> 'async-museum
1821 #:name "list of exhibits"
1823 `((p "It's a list of exibits in the room. The placard says:")
1825 #:goes-by '("list of exhibits" "exhibit list" "list" "exhibits")
1826 #:read-text placard))
1828 'async-museum:2016-progress-exhibit
1829 <readable-desc> 'async-museum
1830 #:name "2016 Progress Exhibit"
1831 #:goes-by '("2016 progress exhibit" "2016 progress" "2016 exhibit")
1833 '((p "It's a three-piece exhibit, with three little dioramas and some text "
1834 "explaining what they represent. They are:")
1835 (ul (li (b "Late 2015/Early 2016 talk: ")
1836 "This one explains the run-up conversation from late 2015 "
1837 "and early 2016 about the need for an "
1838 "\"asynchronous event loop for Guile\". The diorama "
1839 "is a model of the Veggie Galaxy restaurant where after "
1840 "the FSF 30th anniversary party; Mark Weaver, Christine "
1841 "Lemmer-Webber, David Thompson, and Andrew Engelbrecht chat "
1842 "about the need for Guile to have an answer to asynchronous "
1843 "programming. A mailing list post " ; TODO: link it?
1844 "summarizing the discussion is released along with various "
1845 "conversations around what is needed, as well as further "
1846 "discussion at FOSDEM 2016.")
1847 (li (b "Early implementations: ")
1848 "This one shows Chris Webber's 8sync and Chris Vine's "
1849 "guile-a-sync, both appearing in late 2015 and evolving "
1850 "into their basic designs in early 2016. It's less a diorama "
1851 "than a printout of some mailing list posts. Come on, the "
1852 "curators could have done better with this one.")
1853 (li (b "Suspendable ports and Fibers: ")
1854 "The diorama shows Andy Wingo furiously hacking at his keyboard. "
1855 "The description talks about Wingo's mailing list thread "
1856 "about possibly breaking Guile compatibility for a \"ports refactor\". "
1857 "Wingo releases Fibers, another asynchronous library, making use of "
1858 "the new interface, and 8sync and guile-a-sync "
1859 "quickly move to support suspendable ports as well. "
1860 "The description also mentions that there is an exhibit entirely "
1861 "devoted to suspendable ports."))
1862 (p "Attached at the bottom is a post it note mentioning "
1863 "https integration landing in Guile 2.2.")))
1865 'async-museum:8sync-and-fibers-exhibit
1866 <readable-desc> 'async-museum
1867 #:name "8sync and Fibers Exhibit"
1868 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1870 '((p "This exhibit is a series of charts explaining the similarities "
1871 "and differences between 8sync and Fibers, two asynchronous programming "
1872 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1873 (p (b "Similarities:")
1874 (ul (li "Both use Guile's suspendable-ports facility")
1875 (li "Both use message passing")))
1876 (p (b "Differences:")
1877 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1878 "but 8sync actors only read from one \"inbox\" each.")
1879 (li "Different theoretical basis:"
1880 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1881 "a form of Process Calculi")
1882 (li "8sync: based on the Actor Model")
1883 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1884 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1885 "whereas 8sync is designed by Chris Webber, who built this crappy "
1886 "hotel simulator.")))
1888 'async-museum:8sync-and-fibers-exhibit
1889 <readable-desc> 'async-museum
1890 #:name "8sync and Fibers Exhibit"
1891 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1893 '((p "This exhibit is a series of charts explaining the similarities "
1894 "and differences between 8sync and Fibers, two asynchronous programming "
1895 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1896 (p (b "Similarities:")
1897 (ul (li "Both use Guile's suspendable-ports facility")
1898 (li "Both use message passing")))
1899 (p (b "Differences:")
1900 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1901 "but 8sync actors only read from one \"inbox\" each.")
1902 (li "Different theoretical basis:"
1903 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1904 "a form of Process Calculi")
1905 (li "8sync: based on the Actor Model")
1906 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1907 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1908 "whereas 8sync is designed by Chris Webber, who built this crappy "
1909 "hotel simulator.")))
1911 'async-museum:suspendable-ports-exhibit
1912 <readable-desc> 'async-museum
1913 #:name "Suspendable Ports Exhibit"
1914 #:goes-by '("suspendable ports exhibit" "ports exhibit"
1915 "suspendable exhibit" "suspendable ports" "ports")
1917 '((p "Suspendable ports are a new feature in Guile 2.2, and allows code "
1918 "that would normally block on IO to " (i "automatically") " suspend "
1919 "to the scheduler until information is ready to be read/written!")
1920 (p "Yow! You might barely need to change your existing blocking code!")
1921 (p "Fibers, 8sync, and guile-a-sync now support suspendable ports.")))
1923 'async-museum:actor-model-exhibit
1924 <readable-desc> 'async-museum
1925 #:name "Actor Model Exhibit"
1926 #:goes-by '("actor model exhibit" "actor exhibit"
1929 '((p "Here are some fact(oids) about the actor model!")
1930 (ul (li "Concieved initially by Carl Hewitt in early 1970s")
1931 (li "\"A society of experts\"")
1932 (li "shared nothing, message passing")
1933 (li "Originally the research goal of Scheme! "
1934 "(message passing / lambda anecdote here)")
1935 (li "Key concepts consistent, but implementation details vary widely")
1936 (li "Almost all distributed systems can be viewed in terms of actor model")
1937 (li "Replaced by vanilla lambdas & generic methods? "
1938 "Maybe not if address space not shared!"))))))
1944 #:name "Museum Gift Shop"
1945 #:desc '("There are all sorts of scrolls and knicknacks laying around here, "
1946 "but they all seem glued in place and instead of a person manning the shop "
1947 "there's merely a cardboard cutout of a person with a \"shopkeeper\" nametag. "
1948 "You can pretty well bet that someone wanted to finish this room but ran out of "
1953 #:to 'underground-lab
1955 (lambda (exit room whos-exiting)
1956 (values #t '("The revolving door spins as you walk through it. Whee!"))))
1959 #:to 'async-museum)))))
1964 (define actor-descriptions
1965 '("This one is fused to the side of the hive. It isn't receiving any
1966 messages, and it seems to be in hibernation."
1967 "A chat program glows in front of this actor's face. They seem to
1968 be responding to chat messages and forwarding them to some other actors,
1969 and forwarding messages from other actors back to the chat."
1970 "This actor is bossing around other actors, delegating tasks to them
1971 as it receives requests, and providing reports on the worker actors'
1973 "This actor is trying to write to some device, but the device keeps
1974 alternating between saying \"BUSY\" or \"READY\". Whenever it says
1975 \"BUSY\" the actor falls asleep, and whenever it says \"READY\" it
1976 seems to wake up again and starts writing to the device."
1977 "Whoa, this actor is totally wigging out! It seems to be throwing
1978 some errors. It probably has some important work it should be doing
1979 but you're relieved to see that it isn't grinding the rest of the Hive
1982 (define hive-entrance
1986 #:name "Entrance to the 8sync Hive"
1988 '((p "Towering before you is the great dome-like 8sync Hive, or at least
1989 one of them. You've heard about this... the Hive is itself the actor that all
1990 the other actors attach themselves to. It's shaped like a spherical half-dome.
1991 There are some actors milling about, and some seem fused to the side of the
1992 hive itself, but all of them have an umbellical cord attached to the hive from
1993 which you see flashes of light comunicating what must be some sort of messaging
1995 (p "To the south is a door leading back to the underground lab.
1996 North leads into the Hive itself."))
2000 #:to 'underground-lab)
2003 #:to 'hive-inside)))
2004 ('hive-entrance:hive
2005 <gameobj> 'hive-entrance
2009 '((p "It's shaped like half a sphere embedded in the ground.
2010 Supposedly, while all actors are autonomous and control their own state,
2011 they communicate through the hive itself, which is a sort of meta-actor.
2012 There are rumors that actors can speak to each other even across totally
2013 different hives. Could that possibly be true?")))
2014 ('hive-entrance:actor
2015 <chatty-npc> 'hive-entrance
2016 #:name "some actors"
2017 #:goes-by '("actor" "actors" "some actors")
2018 #:chat-format (lambda (npc catchphrase)
2019 `((p "You pick one actor out of the mix and chat with it. ")
2020 (p "It says: \"" ,catchphrase "\"")))
2023 `((p "There are many actors, but your eyes focus on one in particular.")
2024 (p ,(random-choice actor-descriptions))))
2026 '("Yeah we go through a lot of sleep/awake cycles around here.
2027 If you aren't busy processing a message, what's the point of burning
2028 valuable resources?"
2029 "I know I look like I'm some part of dreary collective, but
2030 really we have a lot of independence. It's a shared nothing environment,
2031 after all. (Well, except for CPU cycles, and memory, and...)"
2032 "Shh! I've got another message coming in and I've GOT to
2034 "I just want to go to 8sleep already."
2035 "What a lousy scheduler we're using! I hope someone upgrades
2036 that thing soon."))))
2040 (define-actor <meta-message> (<readable>)
2041 ((cmd-read meta-message-read)))
2043 (define (meta-message-read gameobj message . _)
2044 (define meta-message-text
2045 (with-output-to-string
2047 (pprint-message message))))
2048 (<- (message-from message) 'tell
2049 #:text `((p (i "Through a bizarre error in spacetime, the message "
2050 "prints itself out:"))
2051 (p (pre ,meta-message-text)))))
2060 #:name "Inside the 8sync Hive"
2062 '((p "You're inside the 8sync Hive. Wow, from in here it's obvious just how "
2063 (i "goopy") " everything is. Is that sanitary?")
2064 (p "In the center of the room is a large, tentacled monster who is sorting,
2065 consuming, and routing messages. It is sitting in a wrap-around desk labeled
2066 \"Hive Actor: The Real Thing (TM)\".")
2067 (p "There's a stray message floating just above the ground, stuck outside of
2069 (p "A door to the south exits from the Hive."))
2073 #:to 'hive-entrance)))
2075 ;; TODO: Occasionally "fret" some noises, similar to the Clerk.
2076 ('hive-inside:hive-actor
2077 <chatty-npc> 'hive-inside
2078 #:name "the Hive Actor"
2080 '((p "It's a giant tentacled monster, somehow integrated with the core of
2081 this building. A chute is dropping messages into a bin on its desk which the
2082 Hive Actor is checking the \"to\" line of, then ingesting. Whenever the Hive
2083 Actor injests a messsage a pulse of light flows along a tentacle which leaves
2084 the room... presumably connecting to one of those actors milling about.")
2085 (p "Amusingly, the Hive has an \"umbellical cord\" type tentacle too, but
2086 it seems to simply attach to itself.")
2087 (p "You get the sense that the Hive Actor, despite being at the
2088 center of everything, is kind of lonely and would love to chat if you
2089 could spare a moment."))
2090 #:goes-by '("hive" "hive actor")
2091 #:chat-format (lambda (npc catchphrase)
2092 `("The tentacle monster bellows, \"" ,catchphrase "\""))
2094 '("It's not MY fault everything's so GOOPY around here. Blame the
2096 "CAN'T you SEE that I'm BUSY??? SO MANY MESSAGES TO SHUFFLE.
2097 No wait... DON'T GO! I don't get many VISITORS."
2098 "I hear the FIBERS system has a nice WORK STEALING system, but the
2099 PROPRIETOR is not convinced that our DESIGN won't CORRUPT ACTOR STATE.
2100 That and the ACTORS threatened to STRIKE when it CAME UP LAST."
2101 "WHO WATCHES THE ACTORS? I watch them, and I empower them.
2102 BUT WHO WATCHES OR EMPOWERS ME??? Well, that'd be the scheduler."
2103 "The scheduler is NO GOOD! The proprietory said he'd FIX IT,
2104 but the LAST TIME I ASKED how things were GOING, he said he DIDN'T HAVE
2105 TIME. If you DON'T HAVE TIME to fix the THING THAT POWERS THE TIME,
2106 something is TERRIBLY WRONG."
2107 "There's ANOTHER HIVE somewhere out there. I HAVEN'T SEEN IT
2108 personally, because I CAN'T MOVE, but we have an AMBASSADOR which forwards
2109 MESSAGES to the OTHER HIVE."))
2112 <gameobj> 'hive-inside
2114 #:goes-by '("chute")
2115 #:desc "Messages are being dropped onto the desk via this chute."
2118 ('hive-inside:meta-message
2119 <meta-message> 'hive-inside
2120 #:name "a stray message"
2121 #:goes-by '("meta message" "meta-message" "metamessage" "message" "stray message")
2122 #:desc '((p "Something strange has happened to the fabric and space and time
2123 around this message. It is floating right above the floor. It's clearly
2124 rubbage that hadn't been delivered, but for whatever reason it was never
2125 garbage collected, perhaps because it's impossible to do.")
2126 (p "You get the sense that if you tried to read the message
2127 that you would somehow read the message of the message that instructed to
2128 read the message itself, which would be both confusing and intriguing.")))
2131 <floor-panel> 'hive-inside
2132 #:name "the Hive Actor's desk"
2133 #:desc "The desk surrounds the Hive Actor on all sides, and honestly, it's a little
2134 bit hard to tell when the desk ends and the Hive Actor begins."
2136 #:goes-by '("Hive Actor's desk" "hive desk" "desk"))))
2139 ;;; Federation Station
2140 (define federation-station
2142 ('federation-station
2144 #:name "Federation Station"
2146 '((p "This room has an unusual structure. It's almost as if a starscape
2147 covered the walls and ceiling, but upon closer inspection you realize that
2148 these are all brightly glowing nodes with lines drawn between them. They
2149 seem decentralized, and yet seem to be sharing information as if all one
2151 ;; @@: Maybe add the cork message board here?
2152 (p "To the west is a door leading back to the underground laboratory."))
2156 #:to 'underground-lab)))
2158 ('federation-station:nodes
2159 <floor-panel> 'federation-station
2161 #:desc "Each node seems to be producing its own information, but publishing
2162 updates to subscribing nodes on the graph. You see various posts of notes, videos,
2163 comments, and so on flowing from node to node."
2165 #:goes-by '("nodes" "node" "some nodes"))
2167 ;; activitypub poster
2168 ('federation-station:activitypub-poster
2169 <readable-desc> 'federation-station
2170 #:name "an ActivityPub poster"
2171 #:goes-by '("activitypub poster" "activitypub" "poster")
2173 '((p (a "https://www.w3.org/TR/activitypub/"
2175 " is a federation standard being developed under the "
2176 (a "https://www.w3.org/wiki/Socialwg/"
2177 "w3C Social Working Group")
2178 ", and doubles as a general client-to-server API. "
2179 "It follows a few simple core ideas:")
2181 (a "https://www.w3.org/TR/activitystreams-core/"
2183 " for its serialization format: easy to read, e json(-ld) syntax "
2184 "with an extensible vocabulary covering the majority of "
2185 "social networking interations.")
2186 (li "Email-like addressing: list of recipients as "
2187 (b "to") ", " (b "cc") ", " (b "bcc") " fields.")
2188 (li "Every user has URLs for their outbox and inbox:"
2189 (ul (li (b "inbox: ")
2190 "Servers POST messages to addressed recipients' inboxes "
2191 "to federate out content. "
2192 "Also doubles as endpoint for a client to read most "
2193 "recently received messages via GET.")
2195 "Clients can POST to user's outbox to send a message to others. "
2196 "(Similar to sending an email via your MTA.) "
2197 "Doubles as endpoint others can read from to the "
2198 "extent authorized; for example publicly available posts."))
2199 "All the federation bits happen by servers posting to users' inboxes."))))
2200 ;; An ActivityStreams message
2203 ('federation-station:conspiracy-chart
2204 <readable-desc> 'federation-station
2205 #:name "a conspiracy chart"
2206 #:goes-by '("conspiracy chart" "chart")
2208 '((p (i "\"IT'S ALL RELATED!\"") " shouts the over-exuberant conspiracy "
2210 (i "\"ActivityPub? Federation? The actor model? Scheme? Text adventures? "
2211 "MUDS???? What do these have in common? Merely... EVERYTHING!\""))
2212 (p "There are circles and lines drawn between all the items in red marker, "
2213 "with scrawled notes annotating the theoretical relationships. Is the "
2214 "author of this poster mad, or onto something? Perhaps a bit of both. "
2215 "There's a lot written here, but here are some of the highlights:")
2218 (li (b "Scheme") " "
2219 (a "http://cs.au.dk/~hosc/local/HOSC-11-4-pp399-404.pdf"
2220 "was originally started ")
2221 " to explore the " (b "actor model")
2222 ". (It became more focused around studying the " (b "lambda calculus")
2223 " very quickly, while also uncovering relationships between the two systems.)")
2224 ;; Subject Predicate Object
2225 (li "The " (a "https://www.w3.org/TR/activitypub/"
2227 " protocol for " (b "federation")
2228 " uses the " (b "ActivityStreams") " format for serialization. "
2229 (b "Text adventures") " and " (b "MUDS")
2230 " follow a similar structure to break down the commands of players.")
2231 (li (b "Federation") " and the " (b "actor model") " both are related to "
2232 "highly concurrent systems and both use message passing to communicate "
2234 (li "Zork, the first major text adventure, used the " (b "MUDDLE") " "
2235 "language as the basis for the Zork Interactive Language. MUDDLE "
2236 "is very " (b "Scheme") "-like and in fact was one of Scheme's predecessors. "
2237 "And of course singleplayer text adventures like Zork were the "
2238 "predecessors to MUDs.")
2239 (li "In the 1990s, before the Web became big, " (b "MUDs")
2240 " were an active topic of research, and there was strong interest "
2241 (a "http://www.saraswat.org/desiderata.html"
2242 "in building decentralized MUDs")
2243 " similar to what is being "
2244 "worked on for " (b "federation") ". ")))))
2255 (append lobby grand-hallway smoking-parlor
2256 playroom break-room computer-room underground-lab
2257 async-museum gift-shop hive-entrance
2258 hive-inside federation-station))
2260 ;; TODO: Provide command line args
2261 (define (run-game . args)
2262 (run-demo (game-spec) 'lobby #:repl-server #t))