Generative Story Worlds as Linear Logic Programscmartens/int-talk.pdfGenerative Story Worlds as...
Transcript of Generative Story Worlds as Linear Logic Programscmartens/int-talk.pdfGenerative Story Worlds as...
Generative Story Worldsas
Linear Logic ProgramsChris Martens, João Ferreira,
Anne-Gwenn Bosser, and Marc Cavazza
1
Presented at Interactive Narrative TechnologiesJune 18, 2014
Generative Story Worldsas
Linear Logic ProgramsChris Martens, João Ferreira,
Anne-Gwenn Bosser, and Marc Cavazza
2
Presented at Interactive Narrative TechnologiesJune 18, 2014
3
new programming languages for digital narratives
Praxis & Prompter:
4
OLD programming languages for digital narratives(?)
LOGIC
5
old programming languages for digital narratives
LINEAR LOGIC
6
used linear logic as a programming language (Celf)for specifying narrative worlds;
used proof search to generate structured stories.
What we did:
THREE ACTS
7
I. Setup: agent simulation, linear logic, andlogic programming
II. Payoff: Stories as Proofs
III. Promise and Limitations
8
9
greetinsult
complimentgossip
flirt...
social verbs: social state:
knowledgesentiment
emotional statepersonality
belief
10
verbs: rulescausal relationships: resource dependencies
RULES
11
Narrative Actions~
Logical implication
12
the problem with standard logical implication:
buy_soda :has(Alice, $1) ^ wants(Alice, soda) ⇒
has(Alice, soda)
LINEAR LOGIC
13
A -o B
14
buy_soda :has(Alice, $1) * wants(Alice, soda) -o
has(Alice, soda)
15
A * BA -o B
!A
16
A * BA -o {B}
!A
Logic Programming
17
proof search as program execution
18
initial state
Σ Δ0
Celf
query(optional)
A
Δ0, …, ΔΔ ⊢ A?
narrative actions
Logic Programming
19
A -o {B}
Δ, A → Δ, B
Δ = arbitrary context of resources A1, …, An
20
Example in our paper:Shakespearean tragedy world
21
Shakespearean tragedy world
state components:character location, possession,
sentiment toward other characters,goals
22
Shakespearean tragedy worldat <character> <location>has <character> <object>
anger <character> <character>philia <character> <character>
depressed <character>
23
Shakespearean tragedy world
!dead <character>!killed <character> <character>
24
do/insult :
at C L * at C’ L * anger C C’
-o {at C L * at C’ L * anger C C’ anger C’ C * depressed C’}.
25
do/compliment :
at C L * at C’ L * philia C C’
-o {at C L * at C’ L * philia C C’ * philia C’ C}.
26
do/murder : anger C C’ * anger C C’ * anger C C’ * anger C C’ * at C L * at C’ L * has C weapon-o {at C L * !dead C’ * !murdered C C’ * has C weapon}.
27
do/mourn : at C L * philia C C’ * dead C’-o {philia C C’ * at C L * depressed C * depressed C}.
28
do/becomeSuicidal :
at C L * depressed C * depressed C * depressed C * depressed C
-o {at C L * suicidal C * wants C weapon}.
29
do/loot
: at C L * dead C' * has C' O * wants C O
-o {at C L * has C O}.
30
do/comfort : at C L * at C' L *suicidal C' * philia C C' * philia C' C -o {at C L * at C' L * philia C C' * philia C' C * philia C' C}.
31
initial state
32
story_start :init -o
{ at romeo town * at montague mon_house * at capulet cap_house * at mercutio town * at nurse cap_house * at juliet town * at tybalt town * at apothecary town *
has tybalt weapon * has romeo weapon * has apothecary weapon *
...
33
... * anger montague capulet * anger capulet montague * anger tybalt romeo * anger capulet romeo * anger montague tybalt *
philia mercutio romeo * philia romeo mercutio * philia montague romeo * philia capulet juliet * philia juliet nurse * philia nurse juliet *
neutral nurse romeo * neutral mercutio juliet * neutral juliet mercutio * neutral apothecary nurse * neutral nurse apothecary}.
34
final state
35
ending_happy : nonfinal *
actor C * actor C’ *at C L * at C’ L * married C C’ -o {final}.
ending_vengeance : nonfinal *
actor C1 * actor C2 * actor C3 *killed C1 C2 * philia C3 C2 * killed C3 C1
-o {final}.
36
proofs as stories
37
query:init -o {final}
Nondeterminism
38
A -o {B}
Δ, B
A -o {C}
Δ, C
Δ, A
Nondeterminism
39
A -o {B} C -o {D}
Nondeterminism
40
A -o {B}
Δ, B, C
C -o {D}
Δ, A, D
Δ, A, C
Nondeterminism
41
A -o {B}
Δ, B, C
C -o {D}
Δ, A, D
Δ, A, C
Δ, B, D
42
proof ofinit -o {final}:
function (x:init) =let [xs] = r [ys] in …
43
...let {[X73, [X74, [X75, [X76, X77]]]]}
= do/insult/private [a-tybalt, [a-romeo, [X68, [X66, X72]]]] in
let {[X85, [X86, X87]]}
= do/becomeSuicidal [a-romeo, [X79, [X41, [X59, [X52, X77]]]]] in
let {[X88, [X89, [X90, [X91, X92]]]]}
= do/comfort [a-mercutio, [a-romeo, [X78, [X85, [X86, [X81, X83]]]]]] in
let {[X101, [!X102, [!X103, X104]]]}
= do/murder [a-romeo, [a-tybalt, [X58, [X40, [X76, [X51, [X94, [X96, X27]]]]]]]] in
let {[X105, [X106, [X107, X108]]]}
= do/compliment/private [a-nurse, [a-juliet, [X46, [X47, X30]]]] in
let {[X109, [X110, [X111, X112]]]}
= do/compliment/private [a-juliet, [a-nurse, [X106, [X105, X108]]]] in
let {[X113, X114]}= do/loot [a-romeo, [a-tybalt, [X101, [X102, [X26, X87]]]]] in
...
Concurrent Equality
44
r1: A -o B r2: C -o D
“apply r1; apply r2” ~= “apply r2; apply r1”
if A and C are disjoint
45
graphical representation of traces
46
init
do/insult/privatedo/formOpinion/dislike
do/compliment/witnessed
do/travelTo
do/compliment/private
do/murder
do/marry
ending_1
do/steal
do/thinkVengefully
do/mourn
do/becomeSuicidal
cleanup/1
do/eroticize
do/suicide
do/flirt/discrete
47
init
do/insult/privatedo/formOpinion/dislike
do/compliment/witnessed
do/travelTo
do/compliment/private
do/murder
do/marry
ending_1
do/steal
do/thinkVengefully
do/mourn
do/becomeSuicidal
cleanup/1
do/eroticize
do/suicide
do/flirt/discrete
48
queries on sets of traces
49
> exists ending_1
> exists do/thinkVengefully && ̃link do/thinkVengefully do/murder
generative exploration
informative structure
character perspective-agnosticism
50
what does this accomplish?
51
how do simulation designs fail their authors?
52
orphan verbsvs causally connected chains
ACT III
Potential & Limitations
53
54
combining reactive/exploratory+ goal-driven behavior:
A -o G vs A -o {B}(backward & forward chaining)
Additional potential of LL
55
higher-order rules: (A -o B) -o C
Additional potential of LL
56
higher-order rules: (A -o B) -o C
“serendipity:”Forall L. at romeo L * at juliet L -o {eros romeo juliet * at romeo L * at juliet L})
Additional potential of LL
57
Additional potential of LL
dynamic object generation: Exists x:A. ...
makeRoom : has(C, magic door) * at C R -o {Exists r:room. !adjacent R r}
58
limitations
59
limitations(of the tool)
(of the underlying formalism)
60
limitations of the tool:interactivity
history trackingdebugging facilitiesdrama management
61
limitations of the formalism:ability to broadcast actions
nondeterminism and control over probabilities
62
what I plan to address:interactivity
debugging facilitiesability to “broadcast” actions
63
PHASES
Phases (Example)
64
deduplication
phase act {…
} quiesced act -o {phase dedup}.
phase dedup { wants C O * wants C O -o {wants C O}. } quiesced dedup -o {phase act}.
Phases
phase p1 = {...}phase p2 = {...}
quiesced p1 -o {some_token * phase p2}.
quiesced p2 -o {phase p1}.
Blocks connected by specification of quiescence behavior
65
Phases (Example)interactivity
phase world = { rule1 : do Action * … -o {…}. rule2 : do Action * … -o {…}.}
phase player = {get_input : player_turn -o {read #STDIN}.
}
66
67
also possible to implement: broadcast
68
also ongoing:phase invariants
for each phase, constraints on the context…- as an invariant of the phase
- at quiescence
programmer-specified, machine-checked!
FINALE
69
70
the point of formalismis to be able to run
readable specifications
71
the point of formalismis to be able to reason about
readable specifications
72
73
74
linear logic can be used as a programming language for specifying narrative worlds;
to generate narratives& analyze their structure;
potentially the basis for a richer PL.
Takeaway
FINALE
75
Celf: https://github.com/clf/celf
Example from the paper:http://tinyurl.com/int2014-clf
Me: Chris Martens@chrisamaphone
[email protected] to graduate Summer 2015
MINUS WORLD(bonus slides)
76
Cut
77
Δ1 ⊢ A Δ 2, A ⊢ CΔ 1, Δ 2 ⊢ C
Frame Property
78
If Δ1 ⊢ Athen
Δ1, Δ2 ⊢ A * ⨂Δ2
Frame Property (alt)
79
If Δ1 → Δ2
then Δ1, Δ’ → Δ2, Δ’
Relationship between step and deductions
80
Δ1 → Δ2
iff for all CΔ2 ⊢ C implies Δ1 ⊢ C
81
LOGICSare formalisms with
composable consequences
82
LOGICSare formalisms with
composable consequences
Δ ⊢ A Δ’, A ⊢ CΔ’, Δ ⊢ C
Phases (Example)Broadcast
phase act { do C A * in_room C R -o {broadcast C A R}. }quiesced act -o {phase broadcast}.
phase broadcast { broadcast C A R * in_room C' R -o
{notice C' C A * broadcast C A R}. }quiesced broadcast -o {phase notice}.
83
Phases (Example)Broadcast
84
phase notice { broadcast C A R * notice C' C A -o {react C' C A * in_room C' R * broadcast C A R}. }
quiesced notice * broadcast _ _ _ -o {phase react}.
phase react { react C C' (murder ...) * philia C C' -o {...}}
quiesced react -o {phase act}.
Phasesdelimited subsignatures connected by specifications of quiescence behavior.
85
quiesced P * State -o {phase P’ * State’}.
arbitrarily many phaseslooping + branching