Upload
brianna-washington
View
214
Download
0
Embed Size (px)
Citation preview
A Genetic Algorithm A Genetic Algorithm Approach ToApproach To
Interactive Narrative Interactive Narrative GenerationGeneration
TeongJoo Ong and John LeggettTeongJoo Ong and John Leggett
Texas A&M UniversityTexas A&M University
IntroductionIntroduction
Stories are used to convey Stories are used to convey information, cultural values, and information, cultural values, and experiencesexperiences
New technologies have constantly New technologies have constantly provided increasingly sophisticated provided increasingly sophisticated means to tell storiesmeans to tell stories
Recent trend is the convergence of Recent trend is the convergence of technology, entertainment, and art technology, entertainment, and art in the computerin the computer
BackgroundBackground
Interactive storytelling is a major Interactive storytelling is a major research arearesearch area
Many overlapping approaches have Many overlapping approaches have been used:been used:
AI community (Narrative intelligence):AI community (Narrative intelligence): Immersive storytellingImmersive storytelling Emergent storytellingEmergent storytelling Plot-based systemsPlot-based systems Interactive authoring of storiesInteractive authoring of stories Character-based systemsCharacter-based systems
Background (cont.)Background (cont.)
Hypertext community:Hypertext community: Hypertext narrativesHypertext narratives Adaptive hypermediaAdaptive hypermedia Sculptural hypertextSculptural hypertext
Partial listing of related work from these Partial listing of related work from these areas:areas: CHOROS (N. M. CHOROS (N. M. Sgouros) Sgouros) Façade (M. Mataes, A. Stern)Façade (M. Mataes, A. Stern) Card Shark and Storyspace (M. Bernstein)Card Shark and Storyspace (M. Bernstein) Metalinear Cinematic Narrative (K.M. Metalinear Cinematic Narrative (K.M.
Brooks)Brooks) StoryBeads (B. Barry)StoryBeads (B. Barry)
MotivationMotivation The HEFTI storytelling engine attempts to The HEFTI storytelling engine attempts to
merge results and ideas from both merge results and ideas from both communitiescommunities
Recombination, mutation, selection of Recombination, mutation, selection of authored story elements with Genetic authored story elements with Genetic Algorithm (GA)Algorithm (GA)
Generate, remove and traverse links in the Generate, remove and traverse links in the story elements as the story unfolds using the story elements as the story unfolds using the author’s predefined rulesauthor’s predefined rules
Story elements and rules are encoded in XMLStory elements and rules are encoded in XML Provides a small drag-and-drop tool and tree-Provides a small drag-and-drop tool and tree-
view tools for authors to create their storiesview tools for authors to create their stories
DefinitionsDefinitions Story elements – Smallest units in Story elements – Smallest units in
HEFTI’s story search spaceHEFTI’s story search space Story template – Describes Story template – Describes
combinations of various story elements combinations of various story elements at a particular stage in the storyat a particular stage in the story
Template sequences – Subdivision of Template sequences – Subdivision of story template to depict time-based story template to depict time-based relationships among story elementsrelationships among story elements
Story component – Combination of Story component – Combination of story elements, agent scripts and story elements, agent scripts and variables generated by HEFTI based variables generated by HEFTI based on the given set of story templates and on the given set of story templates and elementselements
Generating a StoryGenerating a Story
A story is divided into multiple time steps A story is divided into multiple time steps Chromosomes represent a story componentChromosomes represent a story component Genes represent a collection of story Genes represent a collection of story
elements pertaining to a template elements pertaining to a template sequence within a story templatesequence within a story template
Genes are encoded as floating point Genes are encoded as floating point numbers for convenience of manipulation numbers for convenience of manipulation (as shown later)(as shown later)
Generating a Story (cont.)Generating a Story (cont.)
A gene is generated by constructing valid A gene is generated by constructing valid story element sets based on the current story element sets based on the current state of the story and various conditions and state of the story and various conditions and rules imposed by the author (Encoding)rules imposed by the author (Encoding)
The encoding process is sequential due to The encoding process is sequential due to dependencies and ordering of story elementsdependencies and ordering of story elements
The encoding process is repeated several The encoding process is repeated several times to generate individuals in the GA times to generate individuals in the GA populationpopulation
Generating a Story (cont.)Generating a Story (cont.)
After the evolution process, the After the evolution process, the decoding process steps through each decoding process steps through each of the genes, decoding each gene of the genes, decoding each gene based on its story contextbased on its story context
The end result is a story component The end result is a story component that describes the next story that describes the next story sequencesequence
The process is repeated to generate The process is repeated to generate subsequent story sequencessubsequent story sequences
Generating a Story (cont.)Generating a Story (cont.)
Operations on Story Operations on Story ComponentsComponents
The original genetic operators are The original genetic operators are modified to handle authored ordering modified to handle authored ordering of story elementsof story elements
Chromosome level operators:Chromosome level operators: Single point crossoverSingle point crossover Multi point crossoverMulti point crossover
Gene level operators:Gene level operators: Crossover operatorsCrossover operators MutationMutation
Chromosome OperatorsChromosome Operators
The offsets are chosen to share The offsets are chosen to share similar starting conditions and similar starting conditions and consequencesconsequences
The operator generates permutations The operator generates permutations of the template sequencesof the template sequences
Chromosome A
Chromosome B
Chosen offsets for multipoint crossover
Chromosome A*
Chromosome B*
…
…
…
…
…
…
…
…
Chromosome Operators Chromosome Operators (cont.)(cont.)
An example from The Three Little Pigs An example from The Three Little Pigs ……
Given two chromosomes (A and B) with:Given two chromosomes (A and B) with:Starting conditions: Starting conditions:
Wolf shows up in front of Angela Pig’s houseWolf shows up in front of Angela Pig’s house
Consequences: Consequences:
Wolf eats Angela PigWolf eats Angela Pig If the state of the story is the same for both, If the state of the story is the same for both,
the intermediary stages can be swapped the intermediary stages can be swapped between A and Bbetween A and B
Gene OperatorsGene Operators Alter selection of story Alter selection of story
elementselements Crossover operators are the Crossover operators are the
same as at the chromosome same as at the chromosome level except they crossover level except they crossover story elements instead of story elements instead of genesgenes
Mutation operator changes Mutation operator changes the offset into a list of the offset into a list of possible story elementspossible story elements
Gene A (Before mutation)
Gene A* (After mutation)
1
6
4
3
……
1
6
4
……
1Chosen offset for mutation
Story ThreadsStory Threads
Authors create Authors create potentialpotential story threads story threads Story thread is an Story thread is an indicatorindicator for: for:
1.1. Length of storyLength of story
2.2. Choice of story elements from a story Choice of story elements from a story templatetemplate
3.3. Sets of story templates to be used at Sets of story templates to be used at certain story time stepscertain story time steps
4.4. Rules that change the flow of the storyRules that change the flow of the story
5.5. Evaluation criteria for chromosome fitnessEvaluation criteria for chromosome fitness
Fitness EvaluationFitness Evaluation
HEFTI is free to generate stories that adhere HEFTI is free to generate stories that adhere only so closely (within a threshold) to a story only so closely (within a threshold) to a story threadthread
Fitness evaluation takes place on the Fitness evaluation takes place on the chromosomes of a story threadchromosomes of a story thread
Authors can indicate Authors can indicate preference, preference, indifference, or dislike towards certain story indifference, or dislike towards certain story elements by assigning positive or negative elements by assigning positive or negative values to the story elements values to the story elements
The existence of certain story elements in The existence of certain story elements in story components are influenced accordingly story components are influenced accordingly through the selection mechanisms of GAthrough the selection mechanisms of GA
Story Thread with Story Thread with Fitness EvaluationFitness Evaluation
<timestep order="4" name="wolf's plan" <timestep order="4" name="wolf's plan" loop="{isPigStillAvailable.value} == loop="{isPigStillAvailable.value} == true true AND {isWolfDead.value} == false">AND {isWolfDead.value} == false">
<set type="wolf's plan" ><set type="wolf's plan" > <element name="act_13" <element name="act_13"
addfitness="0.8"/>addfitness="0.8"/></set></set>
</timestep></timestep>
Scenarios of UseScenarios of Use
Interactive fiction: A murder mystery Interactive fiction: A murder mystery with multiple dynamically generated with multiple dynamically generated story threadsstory threads
Sub-module of a computer game Sub-module of a computer game engine that dynamically combines engine that dynamically combines various story and agent scripts from various story and agent scripts from existing story elementsexisting story elements
An educational environment that can An educational environment that can present new concepts in various forms present new concepts in various forms while preserving the goals of the storywhile preserving the goals of the story
ConclusionsConclusions
HEFTI needs a large enough set of HEFTI needs a large enough set of story elements and templates for it to story elements and templates for it to create the story componentscreate the story components
Authoring a story from scratch can be Authoring a story from scratch can be tedioustedious
Story templates allow authors to Story templates allow authors to create story elements at different create story elements at different granularitiesgranularities
Story elements can be reused in Story elements can be reused in similar story settingssimilar story settings
Future WorkFuture Work
Genetic programming might be used Genetic programming might be used to generate agent scripts given the to generate agent scripts given the starting and ending agent actionsstarting and ending agent actions
Evaluation of fitness data on all of Evaluation of fitness data on all of the story variants that HEFTI is the story variants that HEFTI is capable of generatingcapable of generating
Better support for user interaction Better support for user interaction and control of the storyand control of the story