1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016, 2017 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 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 frumpy fellow"
261 '((p " Whoever this is, they looks totally exhausted. They're
262 collapsed into the only comfortable looking chair in the room and you
263 don't get the sense that they're likely to move any time soon.
264 You notice they're wearing a sticker badly adhesed to their clothing
265 which says \"Hotel Proprietor\", but they look so disorganized that you
266 think that can't possibly be true... can it?
267 Despite their exhaustion, you sense they'd be happy to chat with you,
268 though the conversation may be a bit one sided."))
269 #:goes-by '("frumpy fellow" "fellow"
270 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
271 "hotel proprietor" "proprietor")
272 #:catchphrases hotel-owner-grumps)
276 #:name "the Hotel Bricabrac sign"
277 #:desc " It strikes you that there's something funny going on with this sign.
278 Sure enough, if you look at it hard enough, you can tell that someone
279 hastily painted over an existing sign and changed the \"M\" to an \"H\".
281 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
285 "hotel bricabrac sign"
289 <summoning-bell> 'lobby
290 #:name "a shiny brass bell"
291 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
292 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
293 \"ring me for service\". You probably could \"ring the bell\" if you
295 #:summons 'break-room:desk-clerk)
298 <sign-in-form> 'lobby
299 #:name "sign-in form"
300 #:goes-by '("sign-in form" "form" "signin form")
301 #:desc '("It looks like you could sign this form and set your name like so: "
302 (i "sign form as <my-name-here>")))
304 ;; Object: curio cabinets
305 ;; TODO: respond to attempts to open the curio cabinet
308 #:proxy-items '(lobby:porcelain-doll
310 lobby:tea-set lobby:mustard-pot
311 lobby:head-of-elvis lobby:circuitboard-of-evlis
312 lobby:teletype-scroll lobby:orange-cat-phone)
313 #:name "a curio cabinet"
314 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
315 "cabinet of curiosities")
317 (format #f " The curio cabinet is full of all sorts of oddities!
318 Something catches your eye!
319 Ooh, ~a!" (random-choice
320 '("a creepy porcelain doll"
321 "assorted 1950s robots"
322 "an exquisite tea set"
323 "an antique mustard pot"
324 "the pickled head of Elvis"
325 "the pickled circuitboard of EVLIS"
326 "a scroll of teletype paper holding the software Four Freedoms"
327 "a telephone shaped like an orange cartoon cat")))))
329 ('lobby:porcelain-doll
330 <cabinet-item> 'lobby
332 #:name "a creepy porcelain doll"
333 #:desc "It strikes you that while the doll is technically well crafted,
334 it's also the stuff of nightmares."
335 #:goes-by '("porcelain doll" "doll"))
337 <cabinet-item> 'lobby
339 #:name "a set of 1950s robots"
340 #:desc "There's a whole set of these 1950s style robots.
341 They seem to be stamped out of tin, and have various decorations of levers
342 and buttons and springs. Some of them have wind-up knobs on them."
343 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
345 <cabinet-item> 'lobby
348 #:desc "A complete tea set. Some of the cups are chipped.
349 You can imagine yourself joining a tea party using this set, around a
350 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
351 #:goes-by '("tea set" "tea"))
353 <cabinet-item> 'lobby
355 #:name "cups from the tea set"
356 #:desc "They're chipped."
359 <cabinet-item> 'lobby
361 #:name "a mustard pot"
362 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
363 nice design, and it's an antique, but you can't imagine putting something
364 like this in a museum.")
365 (p "Ha... imagine that... a mustard museum."))
366 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
367 ('lobby:head-of-elvis
368 <cabinet-item> 'lobby
370 #:name "the pickled head of Elvis"
371 #:desc '((p "It's a jar full of some briny-looking liquid and...
372 a free floating head. The head looks an awful lot like Elvis, and
373 definitely not the younger Elvis. The hair even somehow maintains
374 that signature swoop while suspended in liquid. But of course it's
376 (p "Oh, wait, it has a label at the bottom which says:
377 \"This is really the head of Elvis\". Well... maybe don't believe
378 everything you read."))
379 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
380 "elvis" "Elvis" "head" "pickled head"))
381 ('lobby:circuitboard-of-evlis
382 <cabinet-item> 'lobby
384 #:name "the pickled circuitboard of Evlis"
385 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
386 This is quite the find, and you bet just about anyone interested in
387 preserving computer history would love to get their hands on this.")
388 (p "Unfortunately, whatever moron did acquire this has
389 no idea what it means to preserve computers, so here it is floating
390 in some kind of briny liquid. It appears to be heavily corroded.
392 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
393 "pickled circuitboard of EVLIS"
394 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
395 ('lobby:teletype-scroll
396 <cabinet-item> 'lobby
398 #:name "a scroll of teletype"
399 #:desc '((p "This is a scroll of teletype paper. It's a bit old
400 and yellowed but the type is very legible. It says:")
403 (p (strong "== The four essential freedoms =="))
404 (p "A program is free software if the program's users have
405 the four essential freedoms: ")
406 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
407 (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.")
408 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
409 (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.")))
410 (p "You get this feeling that ambiguities in the
411 English language surrounding the word 'free' have lead to a lot of terminology debates."))
412 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
413 "teletype paper" "scroll" "four freedoms"
414 "scroll of teletype paper holding the software Four Freedoms"
415 "scroll of teletype paper holding the software four freedoms"))
416 ('lobby:orange-cat-phone
417 <cabinet-item> 'lobby
419 #:name "a telephone shaped like an orange cartoon cat"
420 #:desc "It's made out of a cheap plastic, and it's very orange.
421 It resembles a striped tabby, and it's eyes hold the emotion of
422 a being both sleepy and smarmy.
423 You suspect that someone, somewhere made a ton of cash on items holding
424 this general shape in the 1990s."
425 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
426 "orange cat phone" "orange cat telephone"
427 "cartoon cat phone" "cartoon cat"
428 "cat phone" "cat telephone" "phone" "telephone"))))
435 (define-actor <disc-shield> (<gameobj>)
436 ((cmd-take disc-shield-take)))
438 (define* (disc-shield-take gameobj message
440 (player (message-from message)))
441 (create-gameobj <glowing-disc> (gameobj-gm gameobj)
442 player) ;; set loc to player to put in player's inventory
444 #:text '((p "As you attempt to pull the shield / disk platter
445 from the statue a shining outline appears around it... and a
446 completely separate, glowing copy of the disc materializes into your
448 (<- (gameobj-loc gameobj) 'tell-room
449 #:text `(,(mbody-val (<-wait player 'get-name))
450 " pulls on the shield of the statue, and a glowing "
451 "copy of it materializes into their hands!")
453 (<- (gameobj-loc gameobj) 'tell-room
455 '(p "You hear a voice whisper: "
456 (i "\"Share the software... and you'll be free...\""))))
458 ;;; This is the disc that gets put in the player's inventory
459 (define-actor <glowing-disc> (<gameobj>)
460 ((cmd-drop glowing-disc-drop-cmd))
462 #:allocation #:each-subclass
463 #:init-thunk (build-props
464 '((hd-platter? . #t))))
465 (name #:allocation #:each-subclass
466 #:init-value "a glowing disc")
467 (desc #:allocation #:each-subclass
468 #:init-value "A brightly glowing disc. It's shaped like a hard
469 drive platter, not unlike the one from the statue it came from. It's
470 labeled \"RL02.5\".")
471 (goes-by #:init-value '("glowing disc" "glowing platter"
472 "glowing disc platter" "glowing disk platter"
473 "platter" "disc" "disk" "glowing shield")))
475 (define* (glowing-disc-drop-cmd gameobj message
477 (player (message-from message)))
479 #:text "You drop the glowing disc, and it shatters into a million pieces!")
480 (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
481 #:text `(,(mbody-val (<-wait player 'get-name))
482 " drops a glowing disc, and it shatters into a million pieces!")
484 (gameobj-self-destruct gameobj))
489 (define lobby-map-text
492 .----------.----------. : & : .----------.----------.
493 | computer | |& :YOU ARE: &| smoking | *UNDER* |
494 | room + playroom + : HERE : + parlor | *CONS- |
495 | > | |& : : &| | TRUCTION*|
496 '----------'----------'-++-------++-'-------+--'----------'
502 (define grand-hallway
506 #:name "Grand Hallway"
507 #:desc '((p " A majestic red carpet runs down the center of the room.
508 Busts of serious looking people line the walls, but there's no
509 clear indication that they have any logical relation to this place.")
510 (p "In the center is a large statue of a woman in a warrior's
511 pose, but something is strange about her weapon and shield. You wonder what
513 (p "To the south is the lobby. A door to the east is labeled \"smoking
514 room\", while a door to the west is labeled \"playroom\"."))
524 #:to 'smoking-parlor)))
526 <readable> 'grand-hallway
527 #:name "the hotel map"
528 #:desc '("This appears to be a map of the hotel. "
529 "Like the hotel itself, it seems to be "
531 "You could read it if you want to.")
532 #:read-text `(pre ,lobby-map-text)
533 #:goes-by '("map" "hotel map"))
534 ('grand-hallway:carpet
535 <gameobj> 'grand-hallway
536 #:name "the Grand Hallway carpet"
537 #:desc "It's very red, except in the places where it's very worn."
539 #:goes-by '("red carpet" "carpet"))
540 ('grand-hallway:busts
541 <gameobj> 'grand-hallway
542 #:name "the busts of serious people"
543 #:desc "There are about 6 of them in total. They look distinguished
544 but there's no indication of who they are."
546 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
547 ('grand-hallway:hackthena-statue
548 <proxy-items> 'grand-hallway
549 #:name "the statue of Hackthena"
550 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
551 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
552 all good hacks, and legendary hacker herself.")
553 (p "Hackthena holds the form of a human woman. She wears flowing
554 robes, has a pear of curly bovine-esque horns protruding from the sides of her
555 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
556 But instead of a weapon, she seems to hold some sort of keyboard. And her
557 shield... well it's round like a shield, but something seems off about it.
558 You'd better take a closer look to be sure."))
559 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
560 #:proxy-items '(grand-hallway:keyboard
561 grand-hallway:disc-platter
562 grand-hallway:hackthena-horns))
563 ('grand-hallway:keyboard
564 <gameobj> 'grand-hallway
565 #:name "a Knight Keyboard"
566 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
567 Any space cadet can see that with that kind of layout a hack-and-slayer could
568 thrash out some serious key-chords like there's no tomorrow. You guess
569 Hackthena must be an emacs user."
574 `("Are you kidding? Do you know how hard it is to find "
575 "a Knight Keyboard? There's no way she's going "
576 "to give that up.")))
577 #:goes-by '("knight keyboard" "keyboard"))
578 ('grand-hallway:hackthena-horns
579 <gameobj> 'grand-hallway
580 #:name "Hackthena's horns"
581 #:desc "They're not unlike a Gnu's horns."
586 `("Are you seriously considering desecrating a statue?")))
587 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
588 ('grand-hallway:disc-platter
589 <disc-shield> 'grand-hallway
590 #:name "Hackthena's shield"
591 #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
592 platter! It has \"RL02.5\" written on it. It looks kind of loose."
594 #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
600 (define-actor <rgb-machine> (<gameobj>)
601 ((cmd-run rgb-machine-cmd-run)
602 (cmd-reset rgb-machine-cmd-reset))
604 #:allocation #:each-subclass
605 #:init-thunk (build-commands
606 (("run" "start") ((direct-command cmd-run)))
607 ("reset" ((direct-command cmd-reset)))))
608 (resetting #:init-value #f
609 #:accessor .resetting)
610 ;; used to reset, and to kick off the first item in the list
611 (rgb-items #:init-keyword #:rgb-items
612 #:accessor .rgb-items))
614 (define (rgb-machine-cmd-run rgb-machine message . _)
615 (define player (message-from message))
617 #:text '("You start the rube goldberg machine."))
618 (<-wait (gameobj-loc rgb-machine) 'tell-room
619 #:text `(,(mbody-val (<-wait player 'get-name))
620 " runs the rube goldberg machine.")
623 (match (.rgb-items rgb-machine)
624 ((first-item rest ...)
625 (<- (dyn-ref rgb-machine first-item) 'trigger))))
627 (define (rgb-machine-cmd-reset rgb-machine message . _)
628 (define player (message-from message))
630 ((not (.resetting rgb-machine))
631 (set! (.resetting rgb-machine) #t)
633 #:text '("You reset the rube goldberg machine."))
634 (<-wait (gameobj-loc rgb-machine) 'tell-room
635 #:text `(,(mbody-val (<-wait player 'get-name))
636 " resets the rube goldberg machine.")
638 (<-wait (gameobj-loc rgb-machine) 'tell-room
639 #:text '("From a panel in the wall, a white gloved mechanical "
640 "arm reaches out to reset all the "
641 "rube goldberg components."))
645 (<- (dyn-ref rgb-machine rgb-item) 'reset)
647 (.rgb-items rgb-machine))
648 (<- (gameobj-loc rgb-machine) 'tell-room
649 #:text "The machine's mechanical arm retreats into the wall!")
650 (set! (.resetting rgb-machine) #f))
653 #:text '("But it's in the middle of resetting right now!")))))
655 (define-actor <rgb-item> (<gameobj>)
656 ((trigger rgb-item-trigger)
657 (reset rgb-item-reset))
658 (invisible? #:init-value #t)
659 (steps #:init-keyword #:steps
661 (triggers-as #:init-value #f
662 #:init-keyword #:triggers-as
663 #:getter .triggers-as)
664 (reset-msg #:init-keyword #:reset-msg
666 ;; States: ready -> running -> ran
667 (state #:init-value 'ready
671 (define (rgb-item-trigger rgb-item message . _)
672 (define room (gameobj-loc rgb-item))
673 (case (.state rgb-item)
675 ;; Set state to running
676 (set! (.state rgb-item) 'running)
678 ;; Loop through all steps
682 ;; A string? That's the description of what's happening, tell players
684 (<- room 'tell-room #:text str))
685 ;; A number? Sleep for that many secs
688 ;; A symbol? That's another gameobj to look up dynamically
690 (<- (dyn-ref rgb-item sym) 'trigger
691 #:triggered-by (.triggers-as rgb-item)))
692 (_ (throw 'unknown-step-type
693 "Don't know how to process rube goldberg machine step type?"
697 ;; We're done! Set state to ran
698 (set! (.state rgb-item) 'ran))
702 #:text `("... but " ,(slot-ref rgb-item 'name)
703 " has already been triggered!")))))
705 (define (rgb-item-reset rgb-item message . _)
706 (define room (gameobj-loc rgb-item))
707 (case (.state rgb-item)
709 (set! (.state rgb-item) 'ready)
711 #:text (.reset-msg rgb-item)))
714 #:text `("... but " ,(slot-ref rgb-item 'name)
715 " is currently running!")))
718 #:text `("... but " ,(slot-ref rgb-item 'name)
719 " has already been reset.")))))
721 (define-actor <rgb-kettle> (<rgb-item>)
722 ((trigger rgb-kettle-trigger)
723 (reset rgb-kettle-reset))
724 (heated #:accessor .heated
726 (filled #:accessor .filled
729 (define* (rgb-kettle-trigger rgb-item message #:key triggered-by)
730 (define room (gameobj-loc rgb-item))
731 (if (not (eq? (.state rgb-item) 'ran))
735 (set! (.state rgb-item) 'running)
736 (set! (.filled rgb-item) #t))
738 (set! (.state rgb-item) 'running)
739 (set! (.heated rgb-item) #t)))
740 (when (and (.filled rgb-item)
743 #:text '((i "*kshhhhhh!*")
744 " The water has boiled!"))
746 (set! (.state rgb-item) 'ran)
747 ;; insert a cup of hot tea in the room
748 (create-gameobj <hot-tea> (gameobj-gm rgb-item) room)
750 #:text '("The machine pours out a cup of hot tea! "
751 "Looks like the machine finished!"))))
753 #:text `("... but " ,(slot-ref rgb-item 'name)
754 " has already been triggered!"))))
756 (define (rgb-kettle-reset rgb-item message . rest-args)
757 (define room (gameobj-loc rgb-item))
758 (when (eq? (.state rgb-item) 'ran)
759 (set! (.heated rgb-item) #f)
760 (set! (.filled rgb-item) #f))
761 (apply rgb-item-reset rgb-item message rest-args))
763 (define-actor <tinfoil-hat> (<gameobj>)
764 ((cmd-wear tinfoil-hat-wear))
766 #:allocation #:each-subclass
767 #:init-thunk (build-commands
768 ("wear" ((direct-command cmd-wear))))))
770 (define (tinfoil-hat-wear tinfoil-hat message . _)
771 (<- (message-from message) 'tell
772 #:text '("You put on the tinfoil hat, and, to be perfectly honest with you "
773 "it's a lot harder to take you seriously.")))
776 (define-actor <hot-tea> (<gameobj>)
777 ((cmd-drink hot-tea-cmd-drink)
778 (cmd-sip hot-tea-cmd-sip))
780 #:allocation #:each-subclass
781 #:init-thunk (build-commands
782 ("drink" ((direct-command cmd-drink)))
783 ("sip" ((direct-command cmd-sip)))))
785 (sips-left #:init-value 4
786 #:accessor .sips-left)
787 (name #:init-value "a cup of hot tea")
788 (take-me? #:init-value #t)
789 (goes-by #:init-value '("cup of hot tea" "cup of tea" "tea" "cup"))
790 (desc #:init-value "It's a steaming cup of hot tea. It looks pretty good!"))
792 (define (hot-tea-cmd-drink hot-tea message . _)
793 (define player (message-from message))
794 (define player-loc (mbody-val (<-wait player 'get-loc)))
795 (define player-name (mbody-val (<-wait player 'get-name)))
797 #:text "You drink a steaming cup of hot tea all at once... hot hot hot!")
798 (<- player-loc 'tell-room
799 #:text `(,player-name
800 " drinks a steaming cup of hot tea all at once.")
802 (gameobj-self-destruct hot-tea))
804 (define (hot-tea-cmd-sip hot-tea message . _)
805 (define player (message-from message))
806 (define player-loc (mbody-val (<-wait player 'get-loc)))
807 (define player-name (mbody-val (<-wait player 'get-name)))
808 (set! (.sips-left hot-tea) (- (.sips-left hot-tea) 1))
810 #:text "You take a sip of your steaming hot tea. How refined!")
811 (<- player-loc 'tell-room
812 #:text `(,player-name
813 " takes a sip of their steaming hot tea. How refined!")
815 (when (= (.sips-left hot-tea) 0)
817 #:text "You've finished your tea!")
818 (<- player-loc 'tell-room
819 #:text `(,player-name
820 " finishes their tea!")
822 (gameobj-self-destruct hot-tea)))
824 (define-actor <fanny-pack> (<container>)
825 ((cmd-take-from-while-wearing cmd-take-from)
826 (cmd-put-in-while-wearing cmd-put-in))
828 #:allocation #:each-subclass
831 (("l" "look") ((direct-command cmd-look-at)))
832 ("take" ((prep-indir-command cmd-take-from-while-wearing
833 '("from" "out of"))))
834 ("put" ((prep-indir-command cmd-put-in-while-wearing
835 '("in" "inside" "into" "on")))))))
841 #:name "The Playroom"
842 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
843 if this room is intended for children or child-like adults.")
844 (" There are doors to both the east and the west."))
851 #:to 'computer-room)))
856 #:desc " It's a little foam cube with googly eyes on it. So cute!")
857 ('playroom:cuddles-plushie
859 #:name "a Cuddles plushie"
860 #:goes-by '("plushie" "cuddles plushie" "cuddles")
862 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
865 <container> 'playroom
867 #:goes-by '("toy chest" "chest")
868 #:desc (lambda (toy-chest whos-looking)
869 (let ((contents (gameobj-occupants toy-chest)))
870 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
873 ,(if (eq? contents '())
874 " nothing! It's empty!"
875 `(ul ,(map (lambda (occupant)
877 (<-wait occupant 'get-name))))
878 (gameobj-occupants toy-chest))))))))
882 ;; Things inside the toy chest
883 ('playroom:toy-chest:rubber-duck
884 <gameobj> 'playroom:toy-chest
885 #:name "a rubber duck"
886 #:goes-by '("rubber duck" "duck")
888 #:desc "It's a yellow rubber duck with a bright orange beak.")
890 ('playroom:toy-chest:tinfoil-hat
891 <tinfoil-hat> 'playroom:toy-chest
892 #:name "a tinfoil hat"
893 #:goes-by '("tinfoil hat" "hat")
895 #:desc "You'd have to be a crazy person to wear this thing!")
897 ('playroom:toy-chest:fanny-pack
898 <fanny-pack> 'playroom:toy-chest
899 #:name "a fanny pack"
900 #:goes-by '("fanny pack" "pack")
903 (lambda (toy-chest whos-looking)
904 (let ((contents (gameobj-occupants toy-chest)))
905 `((p "It's a leather fanny pack, so it's both tacky and kinda cool.")
907 ,(if (eq? contents '())
908 " nothing! It's empty!"
909 `(ul ,(map (lambda (occupant)
911 (<-wait occupant 'get-name))))
912 (gameobj-occupants toy-chest)))))))))
914 ;; Things inside the toy chest
915 ('playroom:toy-chest:fanny-pack:plastic-elephant
916 <gameobj> 'playroom:toy-chest:fanny-pack
917 #:name "a plastic elephant"
918 #:goes-by '("plastic elephant" "elephant")
920 #:desc "It's a tiny little plastic elephant. Small, but heartwarming.")
922 ('playroom:rgb-machine
923 <rgb-machine> 'playroom
924 #:name "a Rube Goldberg machine"
925 #:goes-by '("rube goldberg machine" "machine")
926 #:rgb-items '(playroom:rgb-dominoes
927 playroom:rgb-switch-match
929 playroom:rgb-catapult
930 playroom:rgb-water-demon
931 playroom:rgb-quik-heater
933 #:desc "It's one of those hilarious Rube Goldberg machines.
934 What could happen if you started it?")
937 ('playroom:rgb-dominoes
939 #:name "some dominoes"
940 #:goes-by '("dominoes" "some dominoes")
941 #:steps `("The dominoes topple down the line..."
943 "The last domino lands on a switch!"
945 playroom:rgb-switch-match)
946 #:reset-msg "The dominoes are placed back into position.")
948 ;; Which hit the switch and strike a match
949 ('playroom:rgb-switch-match
952 #:goes-by '("switch" "match")
953 #:steps `("The switch lights a match!"
955 "The match lights a candle!"
958 #:reset-msg "A fresh match is installed and the switch is reset.")
959 ;; which lights a candle and burns a rope
960 ('playroom:rgb-candle
963 #:goes-by '("candle")
964 #:steps `("The candle burns..."
966 "The candle is burning away a rope!"
970 playroom:rgb-catapult)
971 #:reset-msg "A fresh candle is installed.")
972 ;; which catapults a rock
973 ('playroom:rgb-catapult
976 #:goes-by '("catapult")
977 #:steps `("The snapped rope unleashes a catapult, which throws a rock!"
979 "The rock flies through a water demon, startling it!"
981 playroom:rgb-water-demon
983 "The rock whacks into the quik-heater's on button!"
985 playroom:rgb-quik-heater)
987 '("A fresh rope is attached to the catapult, which is pulled taught. "
988 "A fresh rock is placed on the catapult."))
990 ;; '- panics the water demon
991 ;; '- which waters the kettle
992 ('playroom:rgb-water-demon
994 #:name "the water demon"
995 #:triggers-as 'water-demon
996 #:goes-by '("water demon" "demon")
997 #:steps `("The water demon panics, and starts leaking water into the kettle below!"
999 "The kettle is filled!"
1000 playroom:rgb-kettle)
1001 #:reset-msg '("The water demon is scratched behind the ears and calms down."))
1002 ;; '- bops the quik-heater button
1003 ;; '- which heats the kettle
1004 ('playroom:rgb-quik-heater
1005 <rgb-item> 'playroom
1006 #:name "the quik heater"
1007 #:triggers-as 'quik-heater
1008 #:goes-by '("quik heater" "heater")
1009 #:steps `("The quik-heater heats up the kettle above it!"
1011 "The kettle is heated up!"
1012 playroom:rgb-kettle)
1013 #:reset-msg '("The quik heater is turned off."))
1014 ;; Finally, the kettle
1015 ('playroom:rgb-kettle
1016 <rgb-kettle> 'playroom
1018 #:goes-by '("kettle")
1019 #:reset-msg '("The kettle is emptied."))))
1030 ;; ... full of NURPH weapons?
1036 (define-class <furniture> (<gameobj>)
1037 (sit-phrase #:init-keyword #:sit-phrase)
1038 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
1039 (sit-name #:init-keyword #:sit-name)
1042 #:allocation #:each-subclass
1043 #:init-thunk (build-commands
1044 ("sit" ((direct-command cmd-sit-furniture)))))
1045 (actions #:allocation #:each-subclass
1046 #:init-thunk (build-actions
1047 (cmd-sit-furniture furniture-cmd-sit))))
1049 (define* (furniture-cmd-sit actor message #:key direct-obj)
1051 (mbody-val (<-wait (message-from message) 'get-name)))
1052 (<- (message-from message) 'tell
1053 #:text (format #f "You ~a ~a.\n"
1054 (slot-ref actor 'sit-phrase)
1055 (slot-ref actor 'sit-name)))
1056 (<- (slot-ref actor 'loc) 'tell-room
1057 #:text (format #f "~a ~a on ~a.\n"
1059 (slot-ref actor 'sit-phrase-third-person)
1060 (slot-ref actor 'sit-name))
1061 #:exclude (message-from message)))
1064 (define smoking-parlor
1068 #:name "Smoking Parlor"
1070 '((p "This room looks quite posh. There are huge comfy seats you can sit in
1071 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
1072 have installed this place and then changed their mind later.")
1073 (p "There's a door to the west leading back to the grand hallway, and
1074 a nondescript steel door to the south, leading apparently outside."))
1078 #:to 'grand-hallway)
1082 ('smoking-parlor:chair
1083 <furniture> 'smoking-parlor
1084 #:name "a comfy leather chair"
1085 #:desc " That leather chair looks really comfy!"
1086 #:goes-by '("leather chair" "comfy leather chair" "chair")
1087 #:sit-phrase "sink into"
1088 #:sit-phrase-third-person "sinks into"
1089 #:sit-name "the comfy leather chair")
1090 ('smoking-parlor:sofa
1091 <furniture> 'smoking-parlor
1092 #:name "a plush leather sofa"
1093 #:desc " That leather chair looks really comfy!"
1094 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
1095 "leather couch" "plush leather couch" "couch")
1096 #:sit-phrase "sprawl out on"
1097 #:sit-phrase-third-person "sprawls out on into"
1098 #:sit-name "the plush leather couch")
1099 ('smoking-parlor:bar-stool
1100 <furniture> 'smoking-parlor
1101 #:name "a bar stool"
1102 #:desc " Conveniently located near the bar! Not the most comfortable
1103 seat in the room, though."
1104 #:goes-by '("stool" "bar stool" "seat")
1105 #:sit-phrase "hop on"
1106 #:sit-phrase-third-person "hops onto"
1107 #:sit-name "the bar stool")
1109 <chatty-npc> 'smoking-parlor
1110 #:name "Ford Prefect"
1111 #:desc "Just some guy, you know?"
1112 #:goes-by '("Ford Prefect" "ford prefect"
1113 "frood" "prefect" "ford")
1114 #:catchphrases prefect-quotes)
1116 ('smoking-parlor:no-smoking-sign
1117 <readable> 'smoking-parlor
1119 #:name "No Smoking Sign"
1120 #:desc "This sign says \"No Smoking\" in big, red letters.
1121 It has some bits of bubble gum stuck to it... yuck."
1122 #:goes-by '("no smoking sign" "sign")
1123 #:read-text "It says \"No Smoking\", just like you'd expect from
1124 a No Smoking sign.")
1125 ;; TODO: Cigar dispenser
1133 (define-class <desk-clerk> (<gameobj>)
1134 ;; The desk clerk has three states:
1135 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
1137 ;; - slacking: In the break room, probably smoking a cigarette
1138 ;; or checking text messages
1139 (state #:init-value 'slacking)
1140 (commands #:allocation #:each-subclass
1143 (("talk" "chat") ((direct-command cmd-chat)))
1144 ("ask" ((direct-command cmd-ask-incomplete)
1145 (prep-direct-command cmd-ask-about)))
1146 ("dismiss" ((direct-command cmd-dismiss)))))
1147 (patience #:init-value 0)
1148 (actions #:allocation #:each-subclass
1149 #:init-thunk (build-actions
1150 (init clerk-act-init)
1151 (cmd-chat clerk-cmd-chat)
1152 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
1153 (cmd-ask-about clerk-cmd-ask)
1154 (cmd-dismiss clerk-cmd-dismiss)
1155 (update-loop clerk-act-update-loop)
1156 (be-summoned clerk-act-be-summoned))))
1158 (define (clerk-act-init clerk message . _)
1159 ;; call the gameobj main init method
1160 (gameobj-act-init clerk message)
1161 ;; start our main loop
1162 (<- (actor-id clerk) 'update-loop))
1164 (define changing-name-text "Changing your name is easy!
1165 We have a clipboard here at the desk
1166 where you can make yourself known to other participants in the hotel
1167 if you sign it. Try 'sign form as <your-name>', replacing
1168 <your-name>, obviously!")
1171 "Ah... when I'm not here, I've got a PHD to finish.")
1173 (define clerk-help-topics
1174 `(("changing name" . ,changing-name-text)
1175 ("sign-in form" . ,changing-name-text)
1176 ("form" . ,changing-name-text)
1177 ("common commands" .
1178 "Here are some useful commands you might like to try: chat,
1179 go, take, drop, say...")
1181 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
1182 our hotel emphasizes interesting experiences over rest and lodging.
1183 The origins of the hotel are... unclear... and it has recently come
1184 under new... 'management'. But at Hotel Bricabrac we believe these
1185 aspects make the hotel into a fun and unique experience! Please,
1186 feel free to walk around and explore.")
1187 ("physics paper" . ,phd-text)
1188 ("paper" . ,phd-text)
1189 ("proprietor" . "Oh, he's that frumpy looking fellow sitting over there.")))
1192 (define clerk-knows-about
1193 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
1195 (define clerk-general-helpful-line
1197 "The clerk says, \"If you need help with anything, feel free to ask me about it.
1198 For example, 'ask clerk about changing name'. You can ask me about the following:
1199 " clerk-knows-about ".\"\n"))
1201 (define clerk-slacking-complaints
1202 '("The pay here is absolutely lousy."
1203 "The owner here has no idea what they're doing."
1204 "Some times you just gotta step away, you know?"
1205 "You as exhausted as I am?"
1206 "Yeah well, this is just temporary. I'm studying to be a high
1207 energy particle physicist. But ya gotta pay the bills, especially
1208 with tuition at where it is..."))
1210 (define* (clerk-cmd-chat clerk message #:key direct-obj)
1211 (match (slot-ref clerk 'state)
1213 (<- (message-from message) 'tell
1214 #:text clerk-general-helpful-line))
1216 (<- (message-from message) 'tell
1219 "The clerk says, \""
1220 (random-choice clerk-slacking-complaints)
1223 (define (clerk-cmd-ask-incomplete clerk message . _)
1224 (<- (message-from message) 'tell
1225 #:text "The clerk says, \"Ask about what?\"\n"))
1227 (define clerk-doesnt-know-text
1228 "The clerk apologizes and says she doesn't know about that topic.\n")
1230 (define* (clerk-cmd-ask clerk message #:key indir-obj
1232 (match (slot-ref clerk 'state)
1234 (match (assoc indir-obj clerk-help-topics)
1236 (<- (message-from message) 'tell
1238 (string-append "The clerk clears her throat and says:\n \""
1242 (<- (message-from message) 'tell
1243 #:text clerk-doesnt-know-text))))
1245 (<- (message-from message) 'tell
1246 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
1248 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
1249 (match (slot-ref clerk 'state)
1251 (<- who-summoned 'tell
1253 "The clerk tells you as politely as she can that she's already here,
1254 so there's no need to ring the bell.\n"))
1256 (<- (gameobj-loc clerk) 'tell-room
1258 "The clerk's ears perk up, she stamps out a cigarette, and she
1259 runs out of the room!\n")
1260 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
1261 (slot-set! clerk 'patience 8)
1262 (slot-set! clerk 'state 'on-duty)
1263 (<- (gameobj-loc clerk) 'tell-room
1266 " Suddenly, a uniformed woman rushes into the room! She's wearing a
1267 badge that says \"Desk Clerk\".
1268 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
1269 We look forward to your stay. If you'd like help getting acclimated,
1270 feel free to ask me. For example, 'ask clerk about changing name'.
1271 You can ask me about the following:
1272 " clerk-knows-about ".\"\n")))))
1274 (define* (clerk-cmd-dismiss clerk message . _)
1276 (mbody-val (<-wait (message-from message) 'get-name)))
1277 (match (slot-ref clerk 'state)
1279 (<- (gameobj-loc clerk) 'tell-room
1281 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
1282 The clerk leaves the room in a hurry.\n"
1284 #:exclude (actor-id clerk))
1285 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
1286 (slot-set! clerk 'state 'slacking)
1287 (<- (gameobj-loc clerk) 'tell-room
1288 #:text clerk-return-to-slacking-text
1289 #:exclude (actor-id clerk)))
1291 (<- (message-from message) 'tell
1292 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
1294 (define clerk-slacking-texts
1295 '("The clerk takes a long drag on her cigarette.\n"
1296 "The clerk scrolls through text messages on her phone.\n"
1297 "The clerk coughs a few times.\n"
1298 "The clerk checks her watch and justifies a few more minutes outside.\n"
1299 "The clerk fumbles around for a lighter.\n"
1300 "The clerk sighs deeply and exhaustedly.\n"
1301 "The clerk fumbles around for a cigarette.\n"))
1303 (define clerk-working-impatience-texts
1304 '("The clerk hums something, but you're not sure what it is."
1305 "The clerk attempts to change the overhead music, but the dial seems broken."
1306 "The clerk clicks around on the desk computer."
1307 "The clerk scribbles an equation on a memo pad, then crosses it out."
1308 "The clerk mutters something about the proprietor having no idea how to run a hotel."
1309 "The clerk thumbs through a printout of some physics paper."))
1311 (define clerk-slack-excuse-text
1312 "The desk clerk excuses herself, but says you are welcome to ring the bell
1313 if you need further help.")
1315 (define clerk-return-to-slacking-text
1316 "The desk clerk enters and slams the door behind her.\n")
1319 (define (clerk-act-update-loop clerk message)
1320 (define (tell-room text)
1321 (<- (gameobj-loc clerk) 'tell-room
1323 #:exclude (actor-id clerk)))
1324 (define (loop-if-not-destructed)
1325 (if (not (slot-ref clerk 'destructed))
1326 ;; This iterates by "recursing" on itself by calling itself
1327 ;; (as the message handler) again. It used to be that we had to do
1328 ;; this, because there was a bug where a loop which yielded like this
1329 ;; would keep growing the stack due to some parameter goofiness.
1330 ;; That's no longer true, but there's an added advantage to this
1331 ;; route: it's much more live hackable. If we change the definition
1332 ;; of this method, the character will act differently on the next
1333 ;; "tick" of the loop.
1334 (<- (actor-id clerk) 'update-loop)))
1335 (match (slot-ref clerk 'state)
1337 (tell-room (random-choice clerk-slacking-texts))
1338 (8sleep (+ (random 20) 15))
1339 (loop-if-not-destructed))
1341 (if (> (slot-ref clerk 'patience) 0)
1342 ;; Keep working but lose patience gradually
1344 (tell-room (random-choice clerk-working-impatience-texts))
1345 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
1347 (8sleep (+ (random 60) 40))
1348 (loop-if-not-destructed))
1351 (tell-room clerk-slack-excuse-text)
1352 ;; back bto the break room
1353 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
1354 (tell-room clerk-return-to-slacking-text)
1355 ;; annnnnd back to slacking
1356 (slot-set! clerk 'state 'slacking)
1357 (8sleep (+ (random 30) 15))
1358 (loop-if-not-destructed))))))
1365 #:name "Employee Break Room"
1366 #:desc " This is less a room and more of an outdoor wire cage. You get
1367 a bit of a view of the brick exterior of the building, and a crisp wind blows,
1368 whistling, through the openings of the fenced area. Partly smoked cigarettes
1369 and various other debris cover the floor.
1370 Through the wires you can see... well... hm. It looks oddly like
1371 the scenery tapers off nothingness. But that can't be right, can it?"
1375 #:to 'smoking-parlor)))
1376 ('break-room:desk-clerk
1377 <desk-clerk> 'break-room
1378 #:name "the hotel desk clerk"
1379 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
1380 hotel insignia. She appears to be rather exhausted."
1381 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
1383 <gameobj> 'break-room
1386 #:desc "As you stare into the void, the void stares back into you."
1387 #:goes-by '("void" "abyss" "nothingness" "scenery"))
1389 <gameobj> 'break-room
1391 #:name "break room cage"
1392 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
1393 You can see through the gaps, but they're too small to put more than a
1394 couple of fingers through. There appears to be some wear and tear to
1395 the paint, but the wires themselves seem to be unusually sturdy."
1396 #:goes-by '("fence" "cage" "wire cage"))))
1400 ;;; Ennpie's Sea Lounge
1401 ;;; -------------------
1407 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
1408 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
1409 ;; to distinguish both from the real thing.
1411 (define-actor <hard-drive> (<gameobj>)
1412 ((cmd-put-in hard-drive-insert)
1413 (cmd-push-button hard-drive-push-button)
1414 (get-state hard-drive-act-get-state))
1415 (commands #:allocation #:each-subclass
1416 #:init-thunk (build-commands
1417 ("insert" ((prep-indir-command cmd-put-in
1418 '("in" "inside" "into"))))
1419 (("press" "push") ((prep-indir-command cmd-push-button)))))
1420 ;; the state moves from: empty -> with-disc -> loading -> ready
1421 (state #:init-value 'empty
1424 (define (hard-drive-act-get-state hard-drive message)
1425 (<-reply message (.state hard-drive)))
1427 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1428 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
1429 (p "There is a slot where a disk platter could be inserted, "
1430 ,(if (eq? (.state hard-drive) 'empty)
1431 "which is currently empty"
1432 "which contains a glowing platter")
1433 ". There is a LOAD button "
1434 ,(if (member (.state hard-drive) '(empty with-disc))
1436 "which is pressed in and unlit")
1437 ". There is a READY indicator "
1438 ,(if (eq? (.state hard-drive) 'ready)
1441 ,(if (member (.state hard-drive) '(loading ready))
1442 " The machine emits a gentle whirring noise."
1445 (define* (hard-drive-push-button gameobj message
1446 #:key direct-obj indir-obj preposition
1447 (player (message-from message)))
1448 (define (tell-room text)
1449 (<-wait (gameobj-loc gameobj) 'tell-room
1451 (define (tell-room-excluding-player text)
1452 (<-wait (gameobj-loc gameobj) 'tell-room
1456 ((ci-member direct-obj '("button" "load button" "load"))
1457 (tell-room-excluding-player
1458 `(,(mbody-val (<-wait player 'get-name))
1459 " presses the button on the hard disk."))
1461 #:text "You press the button on the hard disk.")
1463 (case (.state gameobj)
1465 ;; I have no idea what this drive did when you didn't have a platter
1466 ;; in it and pressed load, but I know there was a FAULT button.
1467 (tell-room "You hear some movement inside the hard drive...")
1470 '("... but then the FAULT button blinks a couple times. "
1471 "What could be missing?")))
1473 (set! (.state gameobj) 'loading)
1474 (tell-room "The hard disk begins to spin up!")
1476 (set! (.state gameobj) 'ready)
1477 (tell-room "The READY light turns on!"))
1480 #:text '("Pressing the button does nothing right now, "
1481 "but it does feel satisfying.")))))
1484 #:text '("How could you think of pressing anything else "
1485 "but that tantalizing button right in front of you?")))))
1487 (define* (hard-drive-insert gameobj message
1488 #:key direct-obj indir-obj preposition
1489 (player (message-from message)))
1490 (define our-name (slot-ref gameobj 'name))
1494 (for-each (lambda (occupant)
1495 (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1496 (when (ci-member direct-obj goes-by)
1498 (mbody-val (<-wait player 'get-occupants)))
1504 #:text `("You don't seem to have any such " ,direct-obj " to put "
1505 ,preposition " " ,our-name ".")))
1506 ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1508 #:text `("It wouldn't make sense to put "
1509 ,(mbody-val (<-wait this-thing 'get-name))
1510 " " ,preposition " " ,our-name ".")))
1511 ((not (eq? (.state gameobj) 'empty))
1513 #:text "The disk drive already has a platter in it."))
1515 (set! (.state gameobj) 'with-disc)
1517 #:text '((p "You insert the glowing disc into the drive.")
1518 (p "The LOAD button begins to glow."))))))
1521 (define-actor <computer> (<gameobj>)
1522 ((cmd-run-program computer-run-program)
1523 (cmd-run-what (lambda (gameobj message . _)
1524 (<- (message-from message) 'tell
1525 #:text '("The computer is already running, and a program appears "
1527 "you mean to \"run the program on the computer\""))))
1528 (cmd-help-run-not-press
1529 (lambda (gameobj message . _)
1530 (<- (message-from message) 'tell
1531 #:text '("You don't need to press / push / flip anything. "
1532 "You could " (i "run program on computer")
1533 " already if you wanted to.")))))
1534 (commands #:allocation #:each-subclass
1535 #:init-thunk (build-commands
1536 ("run" ((prep-indir-command cmd-run-program
1538 (direct-command cmd-run-what)))
1539 (("press" "push" "flip")
1540 ((prep-indir-command cmd-help-run-not-press))))))
1542 (define* (computer-run-program gameobj message
1543 #:key direct-obj indir-obj preposition
1544 (player (message-from message)))
1546 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
1547 (define (tell-room text)
1548 (<-wait (gameobj-loc gameobj) 'tell-room
1550 (define (tell-room-excluding-player text)
1551 (<-wait (gameobj-loc gameobj) 'tell-room
1554 (define (tell-player text)
1555 (<-wait player 'tell
1558 ((ci-member direct-obj '("program"))
1559 (tell-room-excluding-player
1560 `(,(mbody-val (<-wait player 'get-name))
1561 " runs the program loaded on the computer..."))
1562 (tell-player "You run the program on the computer...")
1565 ((not (eq? (hd-state) 'ready))
1566 (tell-room '("... but it errors out. "
1567 "It seems to be complaining about a " (b "DISK ERROR!")
1568 ". It looks like it is missing some essential software.")))
1570 (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
1574 (define-actor <floor-panel> (<gameobj>)
1575 ;; TODO: Add "open" verb, since obviously people will try that
1576 ((open? (lambda (panel message)
1577 (<-reply message (slot-ref panel 'open))))
1578 (open-up floor-panel-open-up))
1579 (open #:init-value #f))
1581 (define (floor-panel-open-up panel message)
1582 (if (slot-ref panel 'open)
1583 (<- (gameobj-loc panel) 'tell-room
1584 #:text '("You hear some gears grind around the hinges of the "
1585 "floor panel, but it appears to already be open."))
1587 (slot-set! panel 'open #t)
1588 (<- (gameobj-loc panel) 'tell-room
1589 #:text '("You hear some gears grind, as the metal panel on "
1590 "the ground opens and reveals a stairwell going down!")))))
1592 (define* (floor-panel-desc panel #:optional whos-looking)
1593 `("It's a large metal panel on the floor in the middle of the room. "
1594 ,(if (slot-ref panel 'open)
1595 '("It's currently wide open, revealing a spiraling staircase "
1596 "which descends into darkness.")
1597 '("It's currently closed shut, but there are clearly hinges, and "
1598 "it seems like there is a mechanism which probably opens it via "
1599 "some automation. What could be down there?"))))
1601 (define computer-room
1605 #:name "Computer Room"
1606 #:desc (lambda (gameobj whos-looking)
1608 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
1610 `((p "A sizable computer cabinet covers a good portion of the left
1611 wall. It emits a pleasant hum which covers the room like a warm blanket.
1612 Connected to a computer is a large hard drive.")
1613 (p "On the floor is a large steel panel. "
1615 '("It is wide open, exposing a spiral staircase "
1616 "which descends into darkness.")
1617 '("It is closed, but it has hinges which "
1618 "suggest it could be opened.")))))
1625 #:to 'underground-lab
1627 (lambda (exit room whos-exiting)
1629 (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
1632 (values #t "You descend the spiral staircase.")
1633 (values #f '("You'd love to go down, but the only way "
1634 "through is through that metal panel, "
1635 "which seems closed.")))))))
1636 ('computer-room:hard-drive
1637 <hard-drive> 'computer-room
1638 #:name "the hard drive"
1639 #:desc (wrap-apply hard-drive-desc)
1640 #:goes-by '("hard drive" "drive" "hard disk"))
1641 ('computer-room:computer
1642 <computer> 'computer-room
1643 #:name "the computer"
1644 #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
1645 (p "The computer is itself turned on, and it looks like it is "
1646 "all set up for you to run a program on it."))
1647 #:goes-by '("computer"))
1648 ('computer-room:floor-panel
1649 <floor-panel> 'computer-room
1650 #:name "a floor panel"
1651 #:desc (wrap-apply floor-panel-desc)
1653 #:goes-by '("floor panel" "panel"))))
1656 ;;; * UNDERGROUND SECTION OF THE GAME! *
1661 (define underground-map-text
1666 | [8sync Hive] |======' '-_____
1672 .--------------. \\ /
1673 | [Guile Async | .-------+------.
1674 | Museum] | | [Lab] #!#| .-------------.
1675 | @| | MM | |[Federation |
1676 | & ^ +##+@ || < +##| Station]|
1678 | & # | |*You-Are-Here*| '-------------'
1679 | # ^ | #+-------+------'
1680 '-------+------' # #
1684 |@?+%? +#### | ^ f## |
1690 (define 8sync-design-goals
1691 '(ul (li (b "Actor based, shared nothing environment: ")
1692 "Shared resources are hard to control and result in fighting
1693 deadlocks, etc. Escape the drudgery: only one actor controls a resource,
1694 and they only receive one message at a time (though they can \"juggle\"
1696 (li (b "Live hackable: ")
1697 "It's hard to plan out a concurrent system; the right structure
1698 is often found by evolving the system while it runs. Make it easy to
1699 build, shape, and change a running system, as well as observe and correct
1701 (li (b "No callback hell: ")
1702 "Just because you're calling out to some other asynchronous
1703 code doesn't mean you should need to chop up your program into a bunch of bits.
1704 Clever use of delimited continuations makes it easy.")))
1706 (define underground-lab
1710 #:name "Underground laboratory"
1711 #:desc '((p "This appears to be some sort of underground laboratory."
1712 "There is a spiral staircase here leading upwards, where "
1713 "it seems much brighter.")
1714 (p "There are a number of doors leading in different directions:
1715 north, south, east, and west, as well as a revolving door to the southwest.
1716 It looks like it could be easy to get lost, but luckily there
1717 is a map detailing the layout of the underground structure."))
1723 (lambda (exit room whos-exiting)
1724 (values #t "You climb the spiral staircase.")))
1729 (lambda (exit room whos-exiting)
1730 (values #t '("You head west through a fancy-looking entrance. "
1731 "A security guard steps aside for you to pass through, "
1732 "into the room, then stands in front of the door."))))
1735 #:to 'hive-entrance)
1738 #:to 'federation-station)
1742 (lambda (exit room whos-exiting)
1743 (values #f '("Ooh, if only you could go south and check this out! "
1744 "Unfortunately this whole area is sealed off... the proprietor "
1745 "probably never got around to fixing it. "
1746 "Too bad, it would have had monsters to fight and everything!"))))
1750 (lambda (exit room whos-exiting)
1751 (values #f '("Hm, it's one of those revolving doors that only revolves in "
1752 "one direction, and it isn't this one. You guess that while "
1753 "this doesn't appear to be an entrance, it probably is an exit."))))))
1755 ('underground-lab:map
1756 <readable> 'underground-lab
1757 #:name "the underground map"
1758 #:desc '("This appears to be a map of the surrounding area. "
1759 "You could read it if you want to.")
1760 #:read-text `(pre ,underground-map-text)
1761 #:goes-by '("map" "underground map" "lab map"))
1763 ('underground-lab:8sync-sign
1764 <readable> 'underground-lab
1765 #:name "a sign labeled \"8sync design goals\""
1766 #:goes-by '("sign" "8sync design goals sign" "8sync goals" "8sync design" "8sync sign")
1767 #:read-text 8sync-design-goals
1768 #:desc `((p "The sign says:")
1769 ,8sync-design-goals))))
1772 ;;; guile async museum
1774 (define async-museum
1779 #:name "Guile Asynchronous Museum"
1780 #:desc '((p "You're in the Guile Asynchronous Museum. There is a list of exhibits
1781 on the wall near the entrance. Scattered around the room are the exhibits
1782 themselves, but it's difficult to pick them out. Maybe you should read the list
1783 to orient yourself.")
1784 (p "There is a door to the east, watched by a security guard,
1785 as well as an exit leading to the south."))
1792 #:to 'underground-lab
1794 (lambda (exit room whos-exiting)
1795 (values #f '("The security guard stops you and tells you "
1796 "that the only exit is through the gift shop."))))))
1798 'async-museum:security-guard
1799 <chatty-npc> 'async-museum
1800 #:name "a security guard"
1802 '(p "The security guard is blocking the eastern entrance, where "
1803 "you came in from.")
1804 #:goes-by '("security guard" "guard" "security")
1805 #:catchphrases '("It's hard standing here all day."
1806 "I just want to go home."
1807 "The exhibits are nice, but I've seen them all before."))
1809 `((p "Welcome to our humble museum! The exhibits are listed below. "
1811 "To look at one, simply type: " (i "look at <exhibit-name>"))
1812 (p "Available exhibits:")
1813 (ul ,@(map (lambda (exhibit)
1818 "The Actor Model"))))))
1820 'async-museum:list-of-exhibits
1821 <readable> 'async-museum
1822 #:name "list of exhibits"
1824 `((p "It's a list of exibits in the room. The placard says:")
1826 #:goes-by '("list of exhibits" "exhibit list" "list" "exhibits")
1827 #:read-text placard))
1829 'async-museum:2016-progress-exhibit
1830 <readable-desc> 'async-museum
1831 #:name "2016 Progress Exhibit"
1832 #:goes-by '("2016 progress exhibit" "2016 progress" "2016 exhibit")
1834 '((p "It's a three-piece exhibit, with three little dioramas and some text "
1835 "explaining what they represent. They are:")
1836 (ul (li (b "Late 2015/Early 2016 talk: ")
1837 "This one explains the run-up conversation from late 2015 "
1838 "and early 2016 about the need for an "
1839 "\"asynchronous event loop for Guile\". The diorama "
1840 "is a model of the Veggie Galaxy restaurant where after "
1841 "the FSF 30th anniversary party; Mark Weaver, Christopher "
1842 "Allan Webber, David Thompson, and Andrew Engelbrecht chat "
1843 "about the need for Guile to have an answer to asynchronous "
1844 "programming. A mailing list post " ; TODO: link it?
1845 "summarizing the discussion is released along with various "
1846 "conversations around what is needed, as well as further "
1847 "discussion at FOSDEM 2016.")
1848 (li (b "Early implementations: ")
1849 "This one shows Chris Webber's 8sync and Chris Vine's "
1850 "guile-a-sync, both appearing in late 2015 and evolving "
1851 "into their basic designs in early 2016. It's less a diorama "
1852 "than a printout of some mailing list posts. Come on, the "
1853 "curators could have done better with this one.")
1854 (li (b "Suspendable ports and Fibers: ")
1855 "The diorama shows Andy Wingo furiously hacking at his keyboard. "
1856 "The description talks about Wingo's mailing list thread "
1857 "about possibly breaking Guile compatibility for a \"ports refactor\". "
1858 "Wingo releases Fibers, another asynchronous library, making use of "
1859 "the new interface, and 8sync and guile-a-sync "
1860 "quickly move to support suspendable ports as well. "
1861 "The description also mentions that there is an exhibit entirely "
1862 "devoted to suspendable ports."))
1863 (p "Attached at the bottom is a post it note mentioning "
1864 "https integration landing in Guile 2.2.")))
1866 'async-museum:8sync-and-fibers-exhibit
1867 <readable-desc> 'async-museum
1868 #:name "8sync and Fibers Exhibit"
1869 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1871 '((p "This exhibit is a series of charts explaining the similarities "
1872 "and differences between 8sync and Fibers, two asynchronous programming "
1873 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1874 (p (b "Similarities:")
1875 (ul (li "Both use Guile's suspendable-ports facility")
1876 (li "Both use message passing")))
1877 (p (b "Differences:")
1878 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1879 "but 8sync actors only read from one \"inbox\" each.")
1880 (li "Different theoretical basis:"
1881 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1882 "a form of Process Calculi")
1883 (li "8sync: based on the Actor Model")
1884 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1885 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1886 "whereas 8sync is designed by Chris Webber, who built this crappy "
1887 "hotel simulator.")))
1889 'async-museum:8sync-and-fibers-exhibit
1890 <readable-desc> 'async-museum
1891 #:name "8sync and Fibers Exhibit"
1892 #:goes-by '("8sync and fibers exhibit" "8sync exhibit" "fibers exhibit")
1894 '((p "This exhibit is a series of charts explaining the similarities "
1895 "and differences between 8sync and Fibers, two asynchronous programming "
1896 "libraries for GNU Guile. It's way too wordy, but you get the general gist.")
1897 (p (b "Similarities:")
1898 (ul (li "Both use Guile's suspendable-ports facility")
1899 (li "Both use message passing")))
1900 (p (b "Differences:")
1901 (ul (li "Fibers \"processes\" can read from multiple \"channels\", "
1902 "but 8sync actors only read from one \"inbox\" each.")
1903 (li "Different theoretical basis:"
1904 (ul (li "Fibers: based on CSP (Communicating Sequential Processes), "
1905 "a form of Process Calculi")
1906 (li "8sync: based on the Actor Model")
1907 (li "Luckily CSP and the Actor Model are \"dual\"!")))))
1908 (p "Fibers is also designed by Andy Wingo, an excellent compiler hacker, "
1909 "whereas 8sync is designed by Chris Webber, who built this crappy "
1910 "hotel simulator.")))
1912 'async-museum:suspendable-ports-exhibit
1913 <readable-desc> 'async-museum
1914 #:name "Suspendable Ports Exhibit"
1915 #:goes-by '("suspendable ports exhibit" "ports exhibit"
1916 "suspendable exhibit" "suspendable ports" "ports")
1918 '((p "Suspendable ports are a new feature in Guile 2.2, and allows code "
1919 "that would normally block on IO to " (i "automatically") " suspend "
1920 "to the scheduler until information is ready to be read/written!")
1921 (p "Yow! You might barely need to change your existing blocking code!")
1922 (p "Fibers, 8sync, and guile-a-sync now support suspendable ports.")))
1924 'async-museum:actor-model-exhibit
1925 <readable-desc> 'async-museum
1926 #:name "Actor Model Exhibit"
1927 #:goes-by '("actor model exhibit" "actor exhibit"
1930 '((p "Here are some fact(oids) about the actor model!")
1931 (ul (li "Concieved initially by Carl Hewitt in early 1970s")
1932 (li "\"A society of experts\"")
1933 (li "shared nothing, message passing")
1934 (li "Originally the research goal of Scheme! "
1935 "(message passing / lambda anecdote here)")
1936 (li "Key concepts consistent, but implementation details vary widely")
1937 (li "Almost all distributed systems can be viewed in terms of actor model")
1938 (li "Replaced by vanilla lambdas & generic methods? "
1939 "Maybe not if address space not shared!"))))))
1945 #:name "Museum Gift Shop"
1946 #:desc '("There are all sorts of scrolls and knicknacks laying around here, "
1947 "but they all seem glued in place and instead of a person manning the shop "
1948 "there's merely a cardboard cutout of a person with a \"shopkeeper\" nametag. "
1949 "You can pretty well bet that someone wanted to finish this room but ran out of "
1954 #:to 'underground-lab
1956 (lambda (exit room whos-exiting)
1957 (values #t '("The revolving door spins as you walk through it. Whee!"))))
1960 #:to 'async-museum)))))
1965 (define actor-descriptions
1966 '("This one is fused to the side of the hive. It isn't receiving any
1967 messages, and it seems to be in hibernation."
1968 "A chat program glows in front of this actor's face. They seem to
1969 be responding to chat messages and forwarding them to some other actors,
1970 and forwarding messages from other actors back to the chat."
1971 "This actor is bossing around other actors, delegating tasks to them
1972 as it receives requests, and providing reports on the worker actors'
1974 "This actor is trying to write to some device, but the device keeps
1975 alternating between saying \"BUSY\" or \"READY\". Whenever it says
1976 \"BUSY\" the actor falls asleep, and whenever it says \"READY\" it
1977 seems to wake up again and starts writing to the device."
1978 "Whoa, this actor is totally wigging out! It seems to be throwing
1979 some errors. It probably has some important work it should be doing
1980 but you're relieved to see that it isn't grinding the rest of the Hive
1983 (define hive-entrance
1987 #:name "Entrance to the 8sync Hive"
1989 '((p "Towering before you is the great dome-like 8sync Hive, or at least
1990 one of them. You've heard about this... the Hive is itself the actor that all
1991 the other actors attach themselves to. It's shaped like a spherical half-dome.
1992 There are some actors milling about, and some seem fused to the side of the
1993 hive itself, but all of them have an umbellical cord attached to the hive from
1994 which you see flashes of light comunicating what must be some sort of messaging
1996 (p "To the south is a door leading back to the underground lab.
1997 North leads into the Hive itself."))
2001 #:to 'underground-lab)
2004 #:to 'hive-inside)))
2005 ('hive-entrance:hive
2006 <gameobj> 'hive-entrance
2010 '((p "It's shaped like half a sphere embedded in the ground.
2011 Supposedly, while all actors are autonomous and control their own state,
2012 they communicate through the hive itself, which is a sort of meta-actor.
2013 There are rumors that actors can speak to each other even across totally
2014 different hives. Could that possibly be true?")))
2015 ('hive-entrance:actor
2016 <chatty-npc> 'hive-entrance
2017 #:name "some actors"
2018 #:goes-by '("actor" "actors" "some actors")
2019 #:chat-format (lambda (npc catchphrase)
2020 `((p "You pick one actor out of the mix and chat with it. ")
2021 (p "It says: \"" ,catchphrase "\"")))
2024 `((p "There are many actors, but your eyes focus on one in particular.")
2025 (p ,(random-choice actor-descriptions))))
2027 '("Yeah we go through a lot of sleep/awake cycles around here.
2028 If you aren't busy processing a message, what's the point of burning
2029 valuable resources?"
2030 "I know I look like I'm some part of dreary collective, but
2031 really we have a lot of independence. It's a shared nothing environment,
2032 after all. (Well, except for CPU cycles, and memory, and...)"
2033 "Shh! I've got another message coming in and I've GOT to
2035 "I just want to go to 8sleep already."
2036 "What a lousy scheduler we're using! I hope someone upgrades
2037 that thing soon."))))
2041 (define-actor <meta-message> (<readable>)
2042 ((cmd-read meta-message-read)))
2044 (define (meta-message-read gameobj message . _)
2045 (define meta-message-text
2046 (with-output-to-string
2048 (pprint-message message))))
2049 (<- (message-from message) 'tell
2050 #:text `((p (i "Through a bizarre error in spacetime, the message "
2051 "prints itself out:"))
2052 (p (pre ,meta-message-text)))))
2061 #:name "Inside the 8sync Hive"
2063 '((p "You're inside the 8sync Hive. Wow, from in here it's obvious just how "
2064 (i "goopy") " everything is. Is that sanitary?")
2065 (p "In the center of the room is a large, tentacled monster who is sorting,
2066 consuming, and routing messages. It is sitting in a wrap-around desk labeled
2067 \"Hive Actor: The Real Thing (TM)\".")
2068 (p "There's a stray message floating just above the ground, stuck outside of
2070 (p "A door to the south exits from the Hive."))
2074 #:to 'hive-entrance)))
2076 ;; TODO: Occasionally "fret" some noises, similar to the Clerk.
2077 ('hive-inside:hive-actor
2078 <chatty-npc> 'hive-inside
2079 #:name "the Hive Actor"
2081 '((p "It's a giant tentacled monster, somehow integrated with the core of
2082 this building. A chute is dropping messages into a bin on its desk which the
2083 Hive Actor is checking the \"to\" line of, then ingesting. Whenever the Hive
2084 Actor injests a messsage a pulse of light flows along a tentacle which leaves
2085 the room... presumably connecting to one of those actors milling about.")
2086 (p "Amusingly, the Hive has an \"umbellical cord\" type tentacle too, but
2087 it seems to simply attach to itself.")
2088 (p "You get the sense that the Hive Actor, despite being at the
2089 center of everything, is kind of lonely and would love to chat if you
2090 could spare a moment."))
2091 #:goes-by '("hive" "hive actor")
2092 #:chat-format (lambda (npc catchphrase)
2093 `("The tentacle monster bellows, \"" ,catchphrase "\""))
2095 '("It's not MY fault everything's so GOOPY around here. Blame the
2097 "CAN'T you SEE that I'm BUSY??? SO MANY MESSAGES TO SHUFFLE.
2098 No wait... DON'T GO! I don't get many VISITORS."
2099 "I hear the FIBERS system has a nice WORK STEALING system, but the
2100 PROPRIETOR is not convinced that our DESIGN won't CORRUPT ACTOR STATE.
2101 That and the ACTORS threatened to STRIKE when it CAME UP LAST."
2102 "WHO WATCHES THE ACTORS? I watch them, and I empower them.
2103 BUT WHO WATCHES OR EMPOWERS ME??? Well, that'd be the scheduler."
2104 "The scheduler is NO GOOD! The proprietory said he'd FIX IT,
2105 but the LAST TIME I ASKED how things were GOING, he said he DIDN'T HAVE
2106 TIME. If you DON'T HAVE TIME to fix the THING THAT POWERS THE TIME,
2107 something is TERRIBLY WRONG."
2108 "There's ANOTHER HIVE somewhere out there. I HAVEN'T SEEN IT
2109 personally, because I CAN'T MOVE, but we have an AMBASSADOR which forwards
2110 MESSAGES to the OTHER HIVE."))
2113 <gameobj> 'hive-inside
2115 #:goes-by '("chute")
2116 #:desc "Messages are being dropped onto the desk via this chute."
2119 ('hive-inside:meta-message
2120 <meta-message> 'hive-inside
2121 #:name "a stray message"
2122 #:goes-by '("meta message" "meta-message" "metamessage" "message" "stray message")
2123 #:desc '((p "Something strange has happened to the fabric and space and time
2124 around this message. It is floating right above the floor. It's clearly
2125 rubbage that hadn't been delivered, but for whatever reason it was never
2126 garbage collected, perhaps because it's impossible to do.")
2127 (p "You get the sense that if you tried to read the message
2128 that you would somehow read the message of the message that instructed to
2129 read the message itself, which would be both confusing and intriguing.")))
2132 <floor-panel> 'hive-inside
2133 #:name "the Hive Actor's desk"
2134 #:desc "The desk surrounds the Hive Actor on all sides, and honestly, it's a little
2135 bit hard to tell when the desk ends and the Hive Actor begins."
2137 #:goes-by '("Hive Actor's desk" "hive desk" "desk"))))
2140 ;;; Federation Station
2141 (define federation-station
2143 ('federation-station
2145 #:name "Federation Station"
2147 '((p "This room has an unusual structure. It's almost as if a starscape
2148 covered the walls and ceiling, but upon closer inspection you realize that
2149 these are all brightly glowing nodes with lines drawn between them. They
2150 seem decentralized, and yet seem to be sharing information as if all one
2152 ;; @@: Maybe add the cork message board here?
2153 (p "To the west is a door leading back to the underground laboratory."))
2157 #:to 'underground-lab)))
2159 ('federation-station:nodes
2160 <floor-panel> 'federation-station
2162 #:desc "Each node seems to be producing its own information, but publishing
2163 updates to subscribing nodes on the graph. You see various posts of notes, videos,
2164 comments, and so on flowing from node to node."
2166 #:goes-by '("nodes" "node" "some nodes"))
2168 ;; activitypub poster
2169 ('federation-station:activitypub-poster
2170 <readable-desc> 'federation-station
2171 #:name "an ActivityPub poster"
2172 #:goes-by '("activitypub poster" "activitypub" "poster")
2174 '((p (a "https://www.w3.org/TR/activitypub/"
2176 " is a federation standard being developed under the "
2177 (a "https://www.w3.org/wiki/Socialwg/"
2178 "w3C Social Working Group")
2179 ", and doubles as a general client-to-server API. "
2180 "It follows a few simple core ideas:")
2182 (a "https://www.w3.org/TR/activitystreams-core/"
2184 " for its serialization format: easy to read, e json(-ld) syntax "
2185 "with an extensible vocabulary covering the majority of "
2186 "social networking interations.")
2187 (li "Email-like addressing: list of recipients as "
2188 (b "to") ", " (b "cc") ", " (b "bcc") " fields.")
2189 (li "Every user has URLs for their outbox and inbox:"
2190 (ul (li (b "inbox: ")
2191 "Servers POST messages to addressed recipients' inboxes "
2192 "to federate out content. "
2193 "Also doubles as endpoint for a client to read most "
2194 "recently received messages via GET.")
2196 "Clients can POST to user's outbox to send a message to others. "
2197 "(Similar to sending an email via your MTA.) "
2198 "Doubles as endpoint others can read from to the "
2199 "extent authorized; for example publicly available posts."))
2200 "All the federation bits happen by servers posting to users' inboxes."))))
2201 ;; An ActivityStreams message
2204 ('federation-station:conspiracy-chart
2205 <readable-desc> 'federation-station
2206 #:name "a conspiracy chart"
2207 #:goes-by '("conspiracy chart" "chart")
2209 '((p (i "\"IT'S ALL RELATED!\"") " shouts the over-exuberant conspiracy "
2211 (i "\"ActivityPub? Federation? The actor model? Scheme? Text adventures? "
2212 "MUDS???? What do these have in common? Merely... EVERYTHING!\""))
2213 (p "There are circles and lines drawn between all the items in red marker, "
2214 "with scrawled notes annotating the theoretical relationships. Is the "
2215 "author of this poster mad, or onto something? Perhaps a bit of both. "
2216 "There's a lot written here, but here are some of the highlights:")
2219 (li (b "Scheme") " "
2220 (a "http://cs.au.dk/~hosc/local/HOSC-11-4-pp399-404.pdf"
2221 "was originally started ")
2222 " to explore the " (b "actor model")
2223 ". (It became more focused around studying the " (b "lambda calculus")
2224 " very quickly, while also uncovering relationships between the two systems.)")
2225 ;; Subject Predicate Object
2226 (li "The " (a "https://www.w3.org/TR/activitypub/"
2228 " protocol for " (b "federation")
2229 " uses the " (b "ActivityStreams") " format for serialization. "
2230 (b "Text adventures") " and " (b "MUDS")
2231 " follow a similar structure to break down the commands of players.")
2232 (li (b "Federation") " and the " (b "actor model") " both are related to "
2233 "highly concurrent systems and both use message passing to communicate "
2235 (li "Zork, the first major text adventure, used the " (b "MUDDLE") " "
2236 "language as the basis for the Zork Interactive Language. MUDDLE "
2237 "is very " (b "Scheme") "-like and in fact was one of Scheme's predecessors. "
2238 "And of course singleplayer text adventures like Zork were the "
2239 "predecessors to MUDs.")
2240 (li "In the 1990s, before the Web became big, " (b "MUDs")
2241 " were an active topic of research, and there was strong interest "
2242 (a "http://www.saraswat.org/desiderata.html"
2243 "in building decentralized MUDs")
2244 " similar to what is being "
2245 "worked on for " (b "federation") ". ")))))
2256 (append lobby grand-hallway smoking-parlor
2257 playroom break-room computer-room underground-lab
2258 async-museum gift-shop hive-entrance
2259 hive-inside federation-station))
2261 ;; TODO: Provide command line args
2262 (define (run-game . args)
2263 (run-demo (game-spec) 'lobby #:repl-server #t))