Capturing Randomness

So there’s a point in “my” game where one location, #open-desert, is a boundless area; it loops back to itself, but varies the text description and some background objects every time you move.

#open-desert
(room *)
(name *) Open Desert
(inherently dark *)
(look *)
    (select)
        Clouds of dust swirl through the air
    (or)
        The dust storm rages around you
    (or)
        Your tracks are swallowed up in moments by the billowing sand
    (or)
        The desert stretches around you in all directions
    (at random)
    , and
    (select)
        you shiver in the chill night air
    (or)
        you plod wearily through the sand
    (or)
        you wish you could see more than twenty feet in front of you
    (or)
        god damn it's dark
    (or)
        every inch of sand looks just like every other
    (at random)
    .
    (par)
    (visible flotsam $Flotsam)
    (select)
        All you can make out in the darkness
        (is $Flotsam) (a $Flotsam)
    (or)
        You can sort of see (a $Flotsam)
    (or)
        Nearby: (a $Flotsam).
        Nothing to write home about
    (or)
        Half-lost in the shadows, you see
        (a $Flotsam)
        and that's about it
    (at random)
    .

The problem with this is that if you look twice in the same room, the description changes.

So I was thinking; could it be possible to “capture” the RNG and restore it? Something like:

(narrate entering *)
    (collect $Flotsam)
        *(desert flotsam $Flotsam)
        (now) ($Flotsam is nowhere)
    (into $List)
    (shuffle list $List into $Shuffled)
    (take 3 from $Shuffled into $Final)
    (exhaust) {
        *($F is one of $Final)
        (now) ($F is #in *)
    }
    (now) (visible flotsam $Final)
    (capture randomness $Random)
    (now) (desert description randomness $Random)
    (par)
    (try [look])

and

(look *)
    (desert description randomness $Random)
    (using randomness $Random) {
        (select)
            Clouds of dust swirl through the air
        (or)
            The dust storm rages around you
        (or)
...
1 Like

My ultimate solution was to have actual scenery objects and rebuild the list of them each time you move, so if you sit still and look again, you see the same things.

1 Like

My choice would be to store the randomized looks in one or more global variables as closures, update them when entering the open desert and print the look from the variables.

There reason to use closures instead of lists are two-fold: every word in lists are added to the game dictionary by the compiler and lists don’t preserve capitalization while closures do.

Random looks
(global variable (desert look1 $))
(global variable (desert look2 $))

(enter #open-desert)
	(select)
		(now) (desert look1 {Clouds of dust swirl through the air})
	(or)
		(now) (desert look1 {The dust storm rages around you})
	(or)
		(now) (desert look1
			{Your tracks are swallowed up in moments by the billowing sand})
	(or)
		(now) (desert look1 {The desert stretches around you in all directions})
	(at random)

	(select)
		(now) (desert look2 {you shiver in the chill night air})        
	(or)
		(now) (desert look2 {you plod wearily through the sand})
	(or)
		(now) (desert look2
			{you wish you could see more than twenty feet in front of you})
	(or)
		(now) (desert look2 {god damn it's dark})
	(or)
		(now) (desert look2 {every inch of sand looks just like every other})
	(at random)

	(fail)

#open-desert
(room *)
(name *) Open Desert
(look *)
	(desert look1 $Look1)
	(desert look2 $Look2)
	(query $Look1)
	, and
	(query $Look2)
	.
(from * go #east to #track)

#track
(room *)
(name *)		on the dirt track
(look *)		The dirt track leads west to the open desert.
(from * go #west to #open-desert)

#player
(current player #player)
(* is #in #track)
1 Like