§8.19. Random choices of things
Writing "a random number" is not allowed, because the possible range is too large, but that was the only reason why not.
a/-- random (description of values) ... value
This phrase makes a uniformly random choice from values satisfying the description given. Example:
a random visited room
a random scene
A problem message is issued if the range is too large (for instance, "a random text"). Unexpected results may follow if no value fits the description, unless we are describing objects, in which case the result is the special value "nothing".
For instance:
say "You can see [number of adjacent rooms] way[s] from here; how about [random adjacent room]?"
But it's important to worry about the possibility that nothing qualifies - here, that no adjacent rooms exist. The above would then say:
You can see 0 ways from here; how about nothing?
![]() | Start of Chapter 8: Change |
![]() | Back to §8.18. Randomness |
![]() | Onward to Chapter 9: Time: §9.1. When play begins |
|
All we need to do is select the player's destination for him at random:
To avoid infringing the original game too much, let's try a somewhat different setting:
And the following means that the test runs consistently even though the numbers are theoretically random. To make them truly random, remove this line.
Or if we want to add the refinement that the Carousel Room can be switched off:
And then
|
|
All we need to do is select the player's destination for him at random:
To avoid infringing the original game too much, let's try a somewhat different setting:
And the following means that the test runs consistently even though the numbers are theoretically random. To make them truly random, remove this line.
Or if we want to add the refinement that the Carousel Room can be switched off:
And then
All we need to do is select the player's destination for him at random:
To avoid infringing the original game too much, let's try a somewhat different setting:
And the following means that the test runs consistently even though the numbers are theoretically random. To make them truly random, remove this line.
Or if we want to add the refinement that the Carousel Room can be switched off:
And then
|