(Adjacent to) Let’s learn dialog: Finite Switchable Game

So, I read the prompt, started writing something that would be simpler than dealing with a switch, then forgot about that convenience choice and don’t have more time to put into this today.

As usual I’m sure all of this can be done more elegantly in one-third the code:

(story title)	The Last Joybooth Shift
(story author)	Jason Compton

(additional banner text) Based on the tzbits thingo \(and A Mind Forever Voyaging\)

(story release 1)

(story ifid) 2031-2041-2051-2061-2071-2081

(intro)        You are a joybooth operator. Your job is to push the button and provide a moment of joy.(par)
    Just one problem: the solar panels powering your joybooth shop are almost all cracked, the boss hasn't paid the grid bills in months, and people really, really need their joy.
                (par)
                (banner)
                (try [look])

(global variable (pushes left 3))
(global variable (joybooth agitation 0))

%% stolen from advent.dg
($N percent chance)
	(random from 0 to 99 into $X)
	($N > $X)

#button
(name *) button
(descr *) The button that activates a joybooth session.
(#joybooth-east attracts *)
(#joybooth-west attracts *)

(perform [push *]) (pushes left $PL) (joybooth agitation $JA)
    (if) ($PL < 1) (then) Click.

%% stolen from Craverly

    (else) (current room $Room)
        (collect $Obj)
			*($Obj has parent $Room)
			(is addict $Obj)
		(into $List)
    (if) (nonempty $List) (then) (last $List $Addict)
        You push the button and dispense joy.
             ($PL minus 1 into $PLNew)
            (now) (pushes left $PLNew)
            (par) %% There are $PLNew pushes left.
            ($JA divided by 2 into $JANew)
         (now) (joybooth agitation $JANew)
         (now) ($Addict is nowhere)
     (else) No users are here and you don't want to get hooked.
   (endif)
   (endif)

#joybooth-east
(room *)
(name *) Joybooth Bank, east side
(look *) This is the east side of the joybooth shop where you work. You push the big red button to activate a session.
(from * go #west to #joybooth-west)

#joybooth-west
(room *)
(name *) Joybooth Bank, west side
(look *) This is the west side of the joybooth shop where you work. You push the big red button to activate a session.
(from * go #east to #joybooth-east)

#prism
(name *) Perry Simm
(#joybooth-east attracts *)
(#joybooth-west attracts *)
(proper *)
(dict *) perry simm sim prism man
(male *)
(descr *) He seems to be passively minding his own business.
(appearance *) An aged man is standing here, mumbling about
 (select) his buffer?
 (or) a pearl or something.
 (or) prisms? Maybe?
 (or) simulations.
 (purely at random)

#joybooth-wanter-east
(name *) wanter
(dict *) person wanter addict patron
(descr *) A very eager wanter of joy.
(is addict *)
(appearance *) A very eager wanter of joy is here.
(on every tick)
    {~(* is nowhere)} (joybooth agitation $JA) ($JA plus 1 into $JANew) (now) (joybooth agitation $JANew)
(on every tick)
    {(* is nowhere) (33 percent chance)}
    (now) (* is #in #joybooth-east) A new patron has arrived. ~(#player is #in #joybooth-east) Elsewhere.
    
#joybooth-wanter-west
(name *) addict
(dict *) person wanter addict patron
(descr *) An obvious joybooth addict.
(is addict *)
(appearance *) An obvious joybooth addict is here.
(on every tick)
    {~(* is nowhere)} (joybooth agitation $JA) ($JA plus 1 into $JANew) (now) (joybooth agitation $JANew)
(on every tick)
    {(* is nowhere) (33 percent chance)}
    (now) (* is #in #joybooth-west) A new patron has arrived. ~(#player is #in #joybooth-west) Elsewhere.

#player
(current player *)
(* is #in #joybooth-east)
(descr *) You are a joybooth operator. It's a living.
(on every tick)
    (joybooth agitation $JA) 
    (if) ($JA > 8) ($JA < 16) (then) The joybooth enthusiasts are starting to sound agitated. If they don't get their joy, they can get ugly. (endif)
    (if) ($JA > 15) (then) The addicts can't control themselves anymore and achieve a moment of bliss by tearing you limb from limb. The old man just watches, transfixed. (game over {Your nightmare has ended.}) (endif)

2 Likes

(fun fact: at first pushing the button was a flat minus 4 to the agitation level but then after some weird results I remembered that you can’t go below zero, so rather than do fiddly limit math I just went with the safer and more compact divide-by-two)

Neat. It’s like a textual Overcooked 2 but with imposing joy instead of food.

If you create a challenge for a shared resource using attracts, I’m already there!

Indeed, I had an idea for something like that in my notes. Now officially added :slight_smile: :

https://github.com/tzbits/learn-dialog?tab=readme-ov-file#3-the-attracts-game

The Attracts Game: Use ($Room attracts $Obj) to make something
visible from several different rooms simultaneously, for example,
a giant statue, a distant mountain, or a machine spanning
multiple regions of an area. This mechanic ensures a single
object remains in the player’s scope across various locations,
effectively simulating a larger physical scale without requiring
the object to be manually moved between rooms.

1 Like

ok, here’s an attracts game. I’m constantly amazed at how setting out to do something simple and staying simple is so difficult.

Play Here: The Chiaroscuro Chamber

Opening Transcript

The sign said “Do Not Enter”, and you had to enter didn’t you? Well, now you somehow got yourself locked in here.

It’s quite dark with only a little light coming through various back-room crevices. A weird mix of curiosity and panic sets in as you think, “How am I going to get out of this room and back to the public part of the museum?”

[PRESS ANY KEY]

The Chiaroscuro Chamber

a let’s learn dialog (attracts *) game by tzbits.
Release 1. Serial number 260109.
Dialog compiler version 0m/03. Library version 0.46.

Chiaroscuro Chamber South

A large a painting hangs by two cables from a picture rail on the north wall directly in front of you: it’s a portrait of a ghastly figure. Is this something historic? Or just an image from some morbid tenebrist’s imagination? Unclear.

> x painting

A bronze plate below the painting hanging in the center of the wall says, “Archduke Oubliette the Ossified, an exquisite chiaroscuro.”

There’s something strange about the painting. Out of the corner of your eye, you saw–did it move?

> n

You walk north.

Chiaroscuro Chamber North

This is the side of the room directly north of the entrance.

The painting is hanging here.

You see a sistrum here.

You nervously eye the painting. The archduke appears to be frowning.

Source code: chiaroscuro.dg

The hard thing about this one is that I made the painting be everywhere, while still needing it to be somewhere.

cool. AFAIK, attracting an object to a location and placing an object in a location are duplicative. the object is automagically moved to the player’s location each turn.

My initial (wrong) mental model of attracts was that it just made things visible from other rooms. One thing that adds to dialog’s “smooth and creamy awesomeness” :slight_smile: is how accessible the standard library is–having to supply it on the command line when debugging is also a nice reminder that there’s all this code sitting there to read to gain more insight into things:

(update environment around player)
	(if) (current player $Player) ($Player is in room $Room) (then)
		(now) (current room $Room)
		(exhaust) {
			*($Room attracts $Object)
			(now) ($Object is #in $Room)
		}
		(recompute visibility)
		(if) ($Room is unvisited) (player can see) (then)
			(now) ($Room is visited)
		(endif)
	(endif)
2 Likes