CHAPTER 3 System Design
3.3 Story Generating and Filtering
國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
3.2.1 Moves and the Story Graph
Once we have conditions and edges to link the fragments into moves, moves can then in turn be linked together to generate complicated plotlines that involve multiple sequences of plot.
Moves can also branch to various other moves through the transitional nodes, thus creating a complicated story graph.
3.3 Story Generating and Filtering
Conditions and characteristics provide ways for the user to restrict the interactive script generation output to stories that conform to certain constraints. To do this, we use a filtering algorithm that evaluates the characteristic tags on story fragments and the conditions on the edges in order to determine if there are any constraints that are violated.
The proposed algorithm is described in Figure 8. A node means a fragment in the story graph. We first assume that the author is very thorough and subjective in adding characteristics to each fragment, tagging all sad story endings with a characteristic called tragedy T. In this case, the user of the system could set a constraint T = false, and the algorithm would perform a traversal through all the possible story paths, removing all the fragments that have the characteristic T+, ensuring that the resulting story is not sad.
Another way to set constraints is by giving values to parameters. Suppose a user would like to experience a story of limited complexity, defined by Propp (1928) as the number of moves (progression from recognition of a lack to its liquidation), with an increasing degree
‧
applied to filter paths that are too long.Figure 8. Algorithm for story generating
In detail, there are five main steps to the algorithm: (1) Setting user constraints (2) Removing contradicting nodes (3) Pasting user constraints (4) Propagating and reversing user constraints (5) Removal of dead ends.
Algorithm 1 Traverse (node N, constraints C)
1:
if C violates descriptors of node N then2: remove node N, and node’s incoming and outgoing edges
3:
end if‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
In the first step the user defines a set of constraints that they would like to see fulfilled in the ultimate outcome. Suppose the user would like a story where E = false (no evil character), M = true (with magical elements), we have an initial story graph as depicted in Figure 9 with the fragments M1F3 tagged with characteristic E, and fragment M1F5 tagged with characteristic M.
Figure 9. Example initial story graph
Once the constraints are set, the algorithm first carries out a depth-first search through the story graph to remove any contradicting nodes, i.e. any nodes tagged with the characteristic ‘E’ in this example, which represents Evil. We do not do anything with the M characteristic. We cannot determine whether a fragment is a desirable one simply by checking for the presence of M, since it may be fulfilled in other fragments of the storyline. The resulting story graph from the first step can be seen in Figure 10, where M1F3 is removed.
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
Figure 10. First step: removing contradicting nodes.
Then from bottom up, the algorithm pastes the user constraints at each edge leading to TheEnd node, which ensures that the constraints are checked to be fulfilled before the story ends. This, however, does not guarantee that the constraints are fulfilled throughout the story, and can easily lead to an illogical story or dead end, since there are no constraints to limit where the story can lead throughout the story graph. Thus we need the third step: to propagate and reverse the constraints throughout the story graph. The act of propagating and reversing is done intermittently: given our current node position P, we take all the constraints on the outgoing edges of P and “reverse” them according to any changes within P. For example, if P is tagged with the characteristic ‘Magic’ and has the parameter change of
‘complexity+=1’ then the user constraints originally ‘Magic=true’ and ‘complexity>=2’ is reversed into only ‘complexity>=1’ indicating that condition of ‘Magic’ is fulfilled, and the complexity was incremented in this node. The union of all the reversed constraints for each
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
edge are propagated and pasted to the incoming edges of P to indicate that at least one of the reversed outgoing edges of P must be satisfied prior to entering P. This process of reversing and propagating ensures that all end constraints (as well as other edge constraints that are reversed along the way) are checked and validated at the beginning of the story. As demonstrated in Figure 11, we can immediately determine that the edge between fragment M1F2 and M1F6 is inappropriate due to the unfulfilled constraint M.
Figure 11. Pasting, reversing, and propagating end conditions
Though propagation and reversing already ensures that no dead ends will occur in the story, for the last step we still remove unfeasible dead ends to generate a complete subgraph (as shown in Figure 12) of the original story of all feasible story paths.
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
Figure 12. Removing dead ends obtaining the final subgraph
Filtering of parameters and characteristics alone do not contribute to a suitable story.
Suppose the algorithm generates a story: Once upon a time there was a man called John. He did many evil things. Then he went to Heaven after he died.
Assuming there no unknown events in the story, even though the story is indeed simple and not of a sad ending, the reader can reasonably doubt the logic of the author. In order to preserve the logic of the story, the conditions that were set in the linking process must be strictly upheld, while ensuring that there are no dead ends.
The filtering and story generation mechanism not only provides personalization on the level of characteristics, but is also applied in our system to maintain story structure using an example of the six modes of plot proposed by Chatman (1980).
‧
Chatman’s six modes of plot:
a. An unqualifiedly good hero fails b. A villainous protagonist fails
c. A noble hero fails through miscalculation d. A villainous protagonist succeeds
e. An unqualifiedly good hero succeeds
f. A noble hero miscalculates, but then is redeemed
We are able to tag the fragments with customized characteristics as indicated below:
Tragedy (T)—Bad ending (combined with Genre) Hero (H)—A good hero
Miscalculation (M)—Hero makes a mistake
Then Chatman’s six modes of plot can be interpreted as the following logical expression of conditions: complexity>=4;‘T’=true; ‘H’=false is shown below in Figure 13.