Interstitial Stories

The system for interstitial stories in Trust & Betrayal was pretty good. Here’s an example:


Since you're in the neighborhood, you decide to stop by Feslym's house to pay your respects to his widow; it is a gesture of respect for the Shepherdship and a way of showing your concern for her welfare. Kira is a tightly-knit community and the tradition of looking after widows and widowers dates back to the earliest days of the colony. You step onto the porch and open the outer door; to your surprise, % opens the inner door, heading outward, at exactly the same moment. The two of you stare at each other for a second; one must yield the way to the other. What do you do? \
\
Wait for and go along with whatever action % takes.
WI+99-BF5P% smiles and steps aside for you.
D4+dF1P%barges past you without saying a word.
\
Demand that % step aside.
IT+50-BD12-dA4-aF4P% steps aside without argument.
50-BA4-aF1P% refuses to acknowledge your demand and brushes past you.
A8-aD4+dF2P% tells you to go to hell and pushes you aside.
\
Step aside, hold the door open, and say, "After you, %!"
DI+99-BA8+aF5P% smiles sweetly and thanks you.
F8P% sneers triumphantly and barges past you.
\
Barge past %, pushing $ aside.
D2/E+BD16-dF4P% meekly steps aside.
50-BA4-aF2P% glares at you and stands ^ ground.
D8+dA8-aF2P% shoves right back and stares you down.
\

The first block of text is the main story; the backslash characters are block terminators. The brown text handles one of the possible responses; the following text blocks all have the same structure. The first line is the reply text presented on the menu of replies available to the player. The next two lines handle the system’s reaction to that selection. Each such reaction begins with a calculation. The calculation is executed as a string of commands to a small RPN calculator. (RPN: Reverse Polish Notation; a FIFO stack). Think of the characters as buttons on a calculator. Capital letters enter a state variable into the accumulator; lower-case letters store the accumulator into the corresponding state variable. For example, the first calculation can be read as follows:

load the value of W (fear of player toward character)
load the value of I (pride of the character)
add them
load a value of 99
subtract it
(B for ‘branch’) if result is positive, skip this line
(I can’t recall what the F-command does, but it reads the following 5)

This sequence of commands serves only to decide what the character does; it doesn’t change any state variables. Basically, depending upon the pride of the character, he will take one of the two choices. If he doesn’t take the first choice, then he takes the second choice.


I see no reason to change this basic structure. Two changes do suggest themselves. First, I might want a less cryptic set of commands. There’s no reason why the first line above couldn’t be:

player other fear other pride + 99 - branch

This means:
push player index
push other character index
pop the first two values and push the fear of those two indeces
push the other character index
pop that index and push the pride of that index
add
push 99
subtract
branch if the result is greater than zero


With modern string-handling methods built right into the libraries of Java, this should not be the problem it was in the bad old days. It would certainly be a lot more readable.

The second change arises from the fact that I no longer use integer calculations; instead, my variables are expressed as BNumbers. This should not be a problem; instead of using a number like 99, I would use .99. It also means that the operators would be BNumber operators. The most important BNumber operator, Blend, would be used in standard RPN format:

push lower value
push higher value
push balance value
pop three values and push Blend of them

Yes, this should be quite easy to do. But I wonder, should I store the interstitial story data as an XML file or an ASCII file? The ASCII format seems easier, but I worry that it might not have the long-term viability that an XML file would have. Still, the ASCII file will be easier to edit. I’ll go with that; if it doesn’t work out, I can write a little program to convert it to XML.