Upload
kerrie-joseph
View
218
Download
0
Embed Size (px)
Citation preview
Comp763: Modern Computer Games
Using Constraint Logic Programmingto Analyze the Chronology in a William Faulkner Story
Jennifer Burg Sheau-Dong Lang
Irwin Chiu HauComputer ScienceMcGill University
Winter 2004
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
Introduction
Narratives• In movies:
» Essential component– Every movie
• In games:» Interesting component
– Some games
Comp763: Modern Computer Games
Introduction
A good story• Quality
» The storyline
» Character Development
» Plot twist
» Logical
Comp763: Modern Computer Games
Introduction
A good story may have• Flaws
• Conflicts
Human beings are• Sensitive to these issues
• Good in spotting conflicts
Comp763: Modern Computer Games
Introduction
Movies / Novels• Conflicts could
» Lead us to confusion
» Ruin the storyline
Games• Conflicts could cause serious problems
» Hinder game completion
Comp763: Modern Computer Games
Introduction
Dealing with conflicts• Detecting
• Removing
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
A Rose For Emily
Novel• Written by William Faulkner
• Originally published on April 30, 1930
The story• Not told in chronological order
• Broken into countless pieces
• Very difficult to understand
Comp763: Modern Computer Games
A Rose For Emily
The challenge• English literature courses
» Story Analysis– Developing a list of the descriptive details associated with Emily
· Her appearance
· Surroundings
– Reconstructing a chronological list of events
• This paper» Analysis
– Events sorting
– Conflicts detection
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
Constraint Logic Programming
In this paper, CLP is applied to analyze the chronology of “A Rose for Emily”
What is CLP?• Family of programming languages that allow
» Declarative problem statements
» Expression of constraints in specialized domains
Comp763: Modern Computer Games
Constraint Logic Programming
CLP language allows a programmer to • Express a problem declaratively rather than
procedurally» Augmented with expression of constraints
– Integers, rational numbers and Boolean values
– Equations and inequalities
• Find a solution» Solving the system of constraints
– Resolution-based inference
– Constraint satisfaction
Comp763: Modern Computer Games
Constraint Logic Programming
CLP is used to solve problems• Circuit design
• Resource allocation
• Discrete optimization applications
• Analyze the Chronology in a William Faulkner Story
• Detecting conflicts in computer games
Comp763: Modern Computer Games
CLP(R) Applied to Time Elements
Analyze the Chronology in a William Faulkner Story
···
Table 1 Variables and Their Meaning
Comp763: Modern Computer Games
CLP(R) Applied to Time Elements
Table 2 Constraints and Their Meaning
···
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
The Constraint Satisfaction Algorithm
CLP program can be divided into two components• An inference engine
» Binding of variables
• A constraint solver» Each inequality constraint: a1x1 + … + anxn ≤ b
» System of constraints
Comp763: Modern Computer Games
Prolog
PROgramming in LOGic A declarative language
• Knowledge Base» Facts
• Inference» Rules
• Query
In this paper, CLP(R) is implemented in Prolog
Comp763: Modern Computer Games
Conflict Sets
The system• Satisfiable
• Not satisfiable
Not satisfiable => There are conflicts• Conflict sets
Comp763: Modern Computer Games
The Conflict in "A Rose for Emily"
B ≥ E D – E ≥ 8 E = B
Comp763: Modern Computer Games
Removing the Conflict
The conflict uncovered by the CLP(R)• Minimal conflict
To resolve the conflict• Removing any conflicting constraint
In this example (A Rose For Emily)• We choose to remove E = B
• And the solver finds 5 solutions
Comp763: Modern Computer Games
A solution for “A Rose for Emily”
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
Useful Extensions
CLP(R) • Useful for chronological sorting of events
» In stories where events are related out-of-order.
How is it related to games?• Adventure games have
» Events
» Puzzles
• CLP(R) can be applied to games
Comp763: Modern Computer Games
Useful Extensions
Providing an graphical interface• define points in time,
• indicate which points are before which others
• give dates where dates are known
• ask for a sort
• receive a list of conflicting constraints
Comp763: Modern Computer Games
Overview
Introduction “A Rose to Emily” by William Faulkner Constraint Logic Programming The Constraint Satisfaction Algorithm and
Conflict Sets Useful Extensions Conclusion
Comp763: Modern Computer Games
Conclusion
Novels / Movies• A story should not have any conflicts
Games • Puzzles and story should not have any conflicts
CLP(R) is a powerful tool• Can be used to analyze a story
» Sort events
» Detect conflicts
Comp763: Modern Computer Games
Questions?
Comp763: Modern Computer Games