Alabaster — 17 of 123

John Cater, Rob Dubbin, Eric Eve, Elizabeth Heller, Jayzee, Kazuki Mishima, Sarah Morayati, Mark Musante, Emily Short, Adam Thornton, and Ziv Wities

Release 1

Chapter 8 - Optimizations

Section 1 - Limiting the quip repository

[The following tricks optimize the behavior of the system by limiting (initially to about 1/5 for Snow White) the number of quips that the game needs to look at during every turn, intensive loop operations. (For characters other than Snow White -- that is to say, the hart and the true princess -- the speed gain is even greater, because their working selection of quips is so small and we no longer have to search against the full pool.)

In practice, this will not always be the ideal optimization pattern; some games might prefer optimization based on scenes or other features. On consideration, the thing to do might be to create a rulebook and allow the author to turn off optimizations that don't contribute helpfully.]

To start talking to (new person - a person):

follow the new-conversation rules for the new person.

The new-conversation rules are an object-based rulebook.

First new-conversation rule for someone (called the new person):

if the current interlocutor is a person:

delete all queued conversation for the current interlocutor;

now the current interlocutor is the new person.

A new-conversation rule for someone (called the new person):

now every quip is in the quip-repository;

repeat with item running through things in the quip-repository: [1]

if item does not quip-supply the new person or the item is unexposed or the item is an NPC-directed quip:

remove the item from play;

if item is one-time and the player recollects the item:

remove the item from play;

if the item is negated by a fact which is known by the player:

remove the item from play.

A new-conversation rule:

repeat with item running through things in the quip-repository: [2]

if the item assumes snow-white-possessed:

if the player does not know snow-white-possessed:

remove the item from play;

if the item assumes blood-sundering:

if the player does not know blood-sundering:

remove the item from play;

if the item assumes snow-white-knows-sundering:

if the player does not know snow-white-knows-sundering:

remove the item from play;

A quip can be exposed or unexposed. A quip is usually unexposed. [More caching hackery.]

When play begins:

now every shallowly-buried quip is exposed.

Carry out someone discussing a quip:

repeat with item running through quips which directly-follow the previous quip:

remove the item from play;

repeat with item running through quips which indirectly-follow the noun:

now the item is exposed;

now the item is in the quip-repository.

Before printing the name of a fact (called the target):

repeat with item running through things in the quip-repository:

if the target negates the item:

remove the item from play. [3]

Before printing the name of snow-white-possessed:

repeat with item running through quips which quip-supply the current interlocutor:

if the item assumes snow-white-possessed:

move the item to the quip-repository.

Before printing the name of blood-sundering:

repeat with item running through quips which quip-supply the current interlocutor:

if the item assumes blood-sundering:

move the item to the quip-repository.

Before printing the name of snow-white-knows-sundering:

repeat with item running through quips which quip-supply the current interlocutor:

if the item assumes snow-white-knows-sundering:

move the item to the quip-repository.

Notes

[1]. This is not strictly necessary (and indeed wouldn't even be desirable if we had a game where you could use the same quips with different NPCs) but it can be used here to speed up performance.

[2]. The selection of these facts is determined by the diagnostic in Section 2 below. It would be a drag on the system to have *every* fact move things into the quip repository -- this would require a lot more searching -- but for facts that open numerous new quips it is worth starting with their quips out of play and moving them later

[3]. A lot of quips are negated by a few specific facts (vampirism-revealed, snow-white-possessed), so this is a way to winnow quickly