Slide 1

Slide 1 text

Creating and Analyzing! Playable Narratives! with Linear Logic Chris Martens 1 Graphics Lab, CMU April 21, 2015

Slide 2

Slide 2 text

Creating and Analyzing! Playable Narratives! with Linear Logic Chris Martens 2 Graphics Lab, CMU April 21, 2015

Slide 3

Slide 3 text

3 Parable of the Polygons (Vi Hart and Nicky Case)

Slide 4

Slide 4 text

4 Causal Understanding

Slide 5

Slide 5 text

5 Outline: ! 1. Background: forms of narrative play 2. Extended example: Shakespeare World 3. Ongoing work: playable specifications

Slide 6

Slide 6 text

6 1. FORMS OF NARRATIVE PLAY

Slide 7

Slide 7 text

7 branching stories

Slide 8

Slide 8 text

8 branching stories Twine (twinery.org)

Slide 9

Slide 9 text

9

Slide 10

Slide 10 text

10 Sam Kabo Ashwell: “Standard Patterns in Choice-Based Games"

Slide 11

Slide 11 text

11 Sam Kabo Ashwell: “Standard Patterns in Choice-Based Games"

Slide 12

Slide 12 text

12 branching stories with state foyer: (set:$key = true) You found a key! [[den]] ! den: (if: not $key)[There is a cabinet here, but you can't open it.] (else: )[There's a cabinet here. [[open it]] ] [[foyer]] ! open it: yay cabinet!

Slide 13

Slide 13 text

13 What’s the structure of a stateful story?

Slide 14

Slide 14 text

14

Slide 15

Slide 15 text

15 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ Petri Net

Slide 16

Slide 16 text

16 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ permanent states Petri Net

Slide 17

Slide 17 text

17 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ Petri Net

Slide 18

Slide 18 text

18 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ Petri Net

Slide 19

Slide 19 text

19 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ Petri Net

Slide 20

Slide 20 text

20 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ choice between actions Petri Net

Slide 21

Slide 21 text

21 JRWRIR\HU RSHQFDELQHW JRWRGHQ NH\ IR\HU ZLQ GHQ Petri Net

Slide 22

Slide 22 text

22 Linear Logic go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open.

Slide 23

Slide 23 text

23 go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open. Linear Logic “atoms” or “(atomic) resources”

Slide 24

Slide 24 text

24 go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open. Linear Logic “lolli:” linear implication

Slide 25

Slide 25 text

25 go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open. Linear Logic antecedents and consequents

Slide 26

Slide 26 text

26 go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open. Linear Logic “tensor:” resource conjunction

Slide 27

Slide 27 text

27 go_to_foyer : in_den -o in_foyer * !key. go_to_den : in_foyer -o in_den. open_cabinet : in_den * key -o in_den * !cabinet_open. Linear Logic “bang:” persistent resources

Slide 28

Slide 28 text

28 another form of narrative play

Slide 29

Slide 29 text

29 greet insult compliment gossip reject ... social verbs: social state: knowledge sentiment emotional state personality beliefs goals

Slide 30

Slide 30 text

30 aka “character-driven” “emergent” “combinatorial” COMPOSITIONAL NARRATIVE

Slide 31

Slide 31 text

31 aka “character-driven” “emergent” “combinatorial” COMPOSITIONAL NARRATIVE One rule might be applied several times, each in a different narrative state. ! Thus: rules must be parametric over narrative states!

Slide 32

Slide 32 text

32 COMPOSITIONAL NARRATIVE Research question: How can we provide computational support to authoring, understanding the structure of, and playing with compositional narratives?

Slide 33

Slide 33 text

33 COMPOSITIONAL NARRATIVE Answer in progress: programming language(s) based on linear logic. Research question: How can we provide computational support to authoring, understanding the structure of, and playing with compositional narratives?

Slide 34

Slide 34 text

34 Outline: ! 1. Background: forms of narrative play 2. Extended example: Shakespeare World 3. Ongoing work: playable specifications

Slide 35

Slide 35 text

35 II. EXTENDED EXAMPLE: SHAKESPEAREAN TRAGEDY STORY WORLD

Slide 36

Slide 36 text

36 at has anger affection depressed dead World state:

Slide 37

Slide 37 text

37 insult: ➡️

Slide 38

Slide 38 text

38 do/insult : ! at Alice L * at Eliza L 
 * anger Alice Eliza! -o ! at Alice L * at Eliza L 
 * anger Alice Eliza
 * anger Eliza Alice 
 * depressed Eliza.!

Slide 39

Slide 39 text

39 do/insult : ! $at Alice L * $at Eliza L 
 * $anger Alice Eliza! -o ! anger Eliza Alice 
 * depressed Eliza.! (notation: $ for resources we want to keep)

Slide 40

Slide 40 text

40 do/insult : ! $at C L * $at C’ L 
 * $anger C C’! -o anger C’ C 
 * depressed C’.! for all C, C’, L

Slide 41

Slide 41 text

41 do/insult : ! $at C L * $at C’ L 
 * $anger C C’! -o anger C’ C 
 * depressed C’.! for all C, C’, L Logic Programming! (aka Relational Programming)

Slide 42

Slide 42 text

42 Main idea of this section: Use linear logic programming (computation = proof search) to generate narratives over a space specified by rules.

Slide 43

Slide 43 text

43 compliment: ➡️

Slide 44

Slide 44 text

44 ➡️ travel_toward:

Slide 45

Slide 45 text

45 murder: ! ! ➡️

Slide 46

Slide 46 text

46 loot: ➡️

Slide 47

Slide 47 text

47

Slide 48

Slide 48 text

48 initial state !adjacent mon_house town.! !adjacent town mon_house.! !adjacent cap_house town.! !adjacent town cap_house.!

Slide 49

Slide 49 text

49

Slide 50

Slide 50 text

50

Slide 51

Slide 51 text

Program Execution 51 A -o B Δ, A → Δ, B Δ = arbitrary context of resources A1, …, An

Slide 52

Slide 52 text

52 6 6¶ 6R6¶  U6R6¶    Q  /RJLF3URJUDP LQLWLDOVWDWH Program execution in CLF (Watkins et al. 2002) as realized by Celf (Schack-Nielsen & Schürmann 2008) quiescence

Slide 53

Slide 53 text

Program Execution 53 At the end we get: ! Δ , the final context ! a trace of rules applied (sequence of narrative actions, AKA story!) n

Slide 54

Slide 54 text

54 x0 : p(romeo,juliet) x1 : q x2 : r =

Slide 55

Slide 55 text

55 rule : p(C,C’) * q -o s(C) x0 : p(romeo,juliet) x1 : q x2 : r

Slide 56

Slide 56 text

56 x3 : s(romeo) x2 : r x0 : p(romeo,juliet) x1 : q x2 : r rule : p(C,C’) * q -o s(C)

Slide 57

Slide 57 text

57 let x3 = rule x0 x1 … x0 : p(romeo,juliet) x1 : q x2 : r x3 : s(romeo) x2 : r rule : p(C,C’) * q -o s(C)

Slide 58

Slide 58 text

58 x3 : s(romeo) x2 : r let x3 = rule x0 x1 … rule2 : r * s(C) -o t(C) * u

Slide 59

Slide 59 text

59 let x3 = rule x0 x1 let [x4, x5] = rule2 x2 x3 … x4 : t(romeo) x5 : u x3 : s(romeo) x2 : r rule2 : r * s(C) -o t(C) * u

Slide 60

Slide 60 text

Nondeterminism 60 A -o B Δ, B A -o C Δ, C Δ, A

Slide 61

Slide 61 text

61 A -o B C -o D

Slide 62

Slide 62 text

62 A -o B C -o D Δ, B, C Δ, A, D Δ, A, C

Slide 63

Slide 63 text

63 A -o B C -o D Δ, B, C Δ, A, D Δ, A, C Δ, B, D

Slide 64

Slide 64 text

64 A -o B C -o D Δ, B, C Δ, A, D Δ, A, C Δ, B, D r1 r2 r2 r1

Slide 65

Slide 65 text

65 A -o B C -o D Δ, B, C Δ, A, D Δ, A, C Δ, B, D r1 r2 r2 r1 let y1 = r1 x1 let y2 = r2 x2 in E let y2 = r2 x2 let y1 = r1 x1 in E

Slide 66

Slide 66 text

66 Δ, B, C Δ, A, D Δ, A, C Δ, B, D r1 r2 r2 r1 Concurrent Equality = let y1 = r1 x1 let y2 = r2 x2 in E let y2 = r2 x2 let y1 = r1 x1 in E

Slide 67

Slide 67 text

67 y1:B y2:D r1 r2 let y2 = r2 x2 let y1 = r1 x1 in E let y1 = r1 x1 let y2 = r2 x2 in E x1:A x2:C

Slide 68

Slide 68 text

68 @KšEJOQHP PU>=HP¡ NKIAK¡ PKSJ¡ =JCAN @Kš?KILHEIAJP JQNOA¡ FQHEAP¡  ?=L‹DKQOA¡ @KšPN=RAH NKIAK¡ PKSJ¡  ?=L‹DKQOA¡ HEGAO =P =JCAN =JCAN HEGAO HEGAO HEGAO HEGAO HEGAO @Kš?KILHEIAJP FQHEAP¡ NKIAK¡ =P =P =P =P =P =P =P =P =P =P

Slide 69

Slide 69 text

69 program traces are! causally-structured stories

Slide 70

Slide 70 text

70 Outline: ! 1. Background: forms of narrative play 2. Extended example: Shakespeare World 3. Ongoing work: playable specifications

Slide 71

Slide 71 text

71 3. ONGOING WORK: PLAYABLE SPECIFICATIONS

Slide 72

Slide 72 text

72 accessible tools for making games

Slide 73

Slide 73 text

73 PuzzleScript

Slide 74

Slide 74 text

74

Slide 75

Slide 75 text

75

Slide 76

Slide 76 text

76 Horizontal [ > Player | No Obstacle ] -> [ PlayerBodyH | PlayerHead1 ] sfx2

Slide 77

Slide 77 text

77 Idea: Replace nondeterminism in the system with human interactor choice.

Slide 78

Slide 78 text

78 move/up/red : move up * at L (player_head red) -o at L (player_head red). ! move/up : move up * at L (player_head C) * next C C' * adj L up L' * empty L' -o -o at L player_body * at L' (player_head L’). ! move/r : move right * at L (player_head C) * adj L right L' * empty L' -o at L player_body * at L' (player_head lime). ! move/l : move left * at L (player_head C) * adj L left L' * empty L' -o at L player_body * at L' (player_head lime). ! % gravity gravity : at L (player_head C) * adj L down L' * empty L' -o at L player_body * at L' (player_head C).

Slide 79

Slide 79 text

79 move/up/red : move up * at L (player_head red) -o at L (player_head red). ! move/up : move up * at L (player_head C) * next C C' * adj L up L' * empty L' -o -o at L player_body * at L' (player_head L’). ! move/r : move right * at L (player_head C) * adj L right L' * empty L' -o at L player_body * at L' (player_head lime). ! move/l : move left * at L (player_head C) * adj L left L' * empty L' -o at L player_body * at L' (player_head lime). ! % gravity gravity : at L (player_head C) * adj L down L' * empty L' -o at L player_body * at L' (player_head C).

Slide 80

Slide 80 text

80 CEPTRE 3 additions to the core language: ! sensing predicates acting predicates stages

Slide 81

Slide 81 text

81 targeted applications: ! 1. game design: easily combine rules from many domains; invent new mechanics and game logics ! 2. distributed algorithms & systems: easily prototype and experiment with local rules and their global behavior

Slide 82

Slide 82 text

82 ONGOING/FUTURE WORK

Slide 83

Slide 83 text

83 language implementation https://github.com/chrisamaphone/interactive-lp

Slide 84

Slide 84 text

84 emergent systems have lots of corner cases => bugs!

Slide 85

Slide 85 text

85 Reasoning Tools ! 1. Statistical analysis of sets of traces 2. Invariant, precondition, and postcondition checking for stages (static or dynamic) 3. Exhaustive analysis (model checking) for certain fragments of the language?

Slide 86

Slide 86 text

86 Reasoning Tools ! 1. Statistical analysis of sets of traces 2. Invariant, precondition, and postcondition checking for stages (static or dynamic) 3. Exhaustive analysis (model checking) for certain fragments of the language?

Slide 87

Slide 87 text

87 Invariant Checking Example: “Whenever the player can reach a locked door, she can also reach its key.” ! for all doors D, reachable(player,D) => reachable(player, key(D))

Slide 88

Slide 88 text

88 CONCLUSION

Slide 89

Slide 89 text

89 Method: Linear logic programming + proof theory ! Results: 1. Structured narrative generation 2. Playable narratives and game sketches

Slide 90

Slide 90 text

90 Takeaway: ! Programming languages based on logic can bring rules, narrative, and code into closer alignment, which aids prototyping, testing, and reasoning of compositional simulations.

Slide 91

Slide 91 text

91 Questions? 7ZLQH %UDQFKLQJ VWRU\ JUDSKV 6WDWHIXO 6WRULHV (PHUJHQW VWRU\WHOOLQJ 7KHDWULFV 3URP :HHN 7KH6LPV /LQHDU /RJLF 3HWUL1HWV &/)&HOI SURJUDPPLQJ ODQJXDJH 7KHVLV VWDWHPHQW 5HVHDUFK 4XHVWLRQ (YLGHQFHIRU GHVLJQWRROSDUW RIWKHVLV VWDWHPHQW UHDVRQLQJ WRROV EXJV &HSWUH VHQVLQJ SUHGLFDWHV 3X]]OH6FULSW (YLGHQFHIRU SURWRW\SLQJDQG DQDO\VLVSDUWRI WKHVLVVWDWHPHQW 3DUW 3DUW 3DUW &/) WUDFHVSURRIV 3URRIVDV VWRULHV 6KDNHVSHDUH ZRUOG /RJLF 3URJUDPPLQJ &RQFXUUHQW VWUXFWXUH Thanks!

Slide 92

Slide 92 text

Extra Slides 92

Slide 93

Slide 93 text

93 Open Q: ! What is the narrative structure of, say, a classic arcade game or single-player RPG? ! Is this structure useful to a designer?

Slide 94

Slide 94 text

94 Hypothesis: ! Concurrent structure of play traces will not be all that interesting (modulo independently-acting NPCs) ! …but Petri Net structure of the rules might be: feedback loops, “orphan verbs,” resource accumulation properties, other design features (& bugs)

Slide 95

Slide 95 text

95 Proof search: ! To run a query \Delta |- B ! Seed \Delta_0 = \Delta Run to quiescence to get \Delta’ Check whether \Delta’ contains everything in B (and nothing more)

Slide 96

Slide 96 text

96 So for instance I could codify endings in Shakespeare world like: ! married A B * dead C -o ending ! then do a query for ! init -o ending ! (in fact this is what I did since Celf doesn’t support traces for goalless queries!)

Slide 97

Slide 97 text

97 Tamara Participatory theatre in which participants may follow any character when they exit a scene ! Many concurrent + reconverging scenes — concurrent structure! ! CLF as dramaturgy tool?