Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creating and Analyzing Playable Narratives with Linear Logic

Chris
April 21, 2015

Creating and Analyzing Playable Narratives with Linear Logic

Computational procedures afford us with a rich design space of narratives that can be explored and played in a variety of ways, and interactive narrative as a field has the potential to help humans understand complex systems of causality. But we need better tools for authoring and conceptualizing playable narratives, especially those that arise from multiple story agents acting interdependently.

I illustrate how linear logic, a general formalism with ties to
computational concurrency, can be used to encode a narrative space in such a way that we can a) run a proof search algorithm to generate different narratives, and b) analyze causal structure. I will then discuss ongoing work in developing a programming language based on linear logic, with the aim of supporting a broad range of idioms in interactive simulation and game design.

Chris

April 21, 2015
Tweet

More Decks by Chris

Other Decks in Research

Transcript

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

    April 21, 2015

    View Slide

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

    April 21, 2015

    View Slide

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

    View Slide

  4. 4
    Causal Understanding

    View Slide

  5. 5
    Outline:

    !
    1. Background: forms of narrative play

    2. Extended example: Shakespeare World

    3. Ongoing work: playable specifications

    View Slide

  6. 6
    1. FORMS OF NARRATIVE PLAY

    View Slide

  7. 7
    branching stories

    View Slide

  8. 8
    branching stories
    Twine (twinery.org)

    View Slide

  9. 9

    View Slide

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

    View Slide

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

    View Slide

  12. 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!

    View Slide

  13. 13
    What’s the structure of a stateful story?

    View Slide

  14. 14

    View Slide

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

    View Slide

  16. 16
    JRWRIR\HU
    RSHQFDELQHW
    JRWRGHQ
    NH\ IR\HU
    ZLQ
    GHQ
    permanent

    states
    Petri Net

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  20. 20
    JRWRIR\HU
    RSHQFDELQHW
    JRWRGHQ
    NH\ IR\HU
    ZLQ
    GHQ
    choice between

    actions
    Petri Net

    View Slide

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

    View Slide

  22. 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.

    View Slide

  23. 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”

    View Slide

  24. 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

    View Slide

  25. 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

    View Slide

  26. 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

    View Slide

  27. 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

    View Slide

  28. 28
    another form of narrative play

    View Slide

  29. 29
    greet

    insult

    compliment

    gossip

    reject

    ...
    social verbs: social state:
    knowledge

    sentiment

    emotional state

    personality

    beliefs

    goals

    View Slide

  30. 30
    aka

    “character-driven”

    “emergent”

    “combinatorial”
    COMPOSITIONAL NARRATIVE

    View Slide

  31. 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!

    View Slide

  32. 32
    COMPOSITIONAL NARRATIVE
    Research question:

    How can we provide computational support to authoring,
    understanding the structure of,

    and playing with compositional narratives?

    View Slide

  33. 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?

    View Slide

  34. 34
    Outline:

    !
    1. Background: forms of narrative play

    2. Extended example: Shakespeare World

    3. Ongoing work: playable specifications

    View Slide

  35. 35
    II. EXTENDED EXAMPLE:

    SHAKESPEAREAN TRAGEDY

    STORY WORLD

    View Slide

  36. 36
    at

    has

    anger

    affection

    depressed

    dead
    World state:

    View Slide

  37. 37
    insult:
    ➡️

    View Slide

  38. 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.!

    View Slide

  39. 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)

    View Slide

  40. 40
    do/insult : !
    $at C L * $at C’ L 

    * $anger C C’!
    -o anger C’ C 

    * depressed C’.!
    for all C, C’, L

    View Slide

  41. 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)

    View Slide

  42. 42
    Main idea of this section:

    Use linear logic programming

    (computation = proof search)

    to generate narratives over a

    space specified by rules.

    View Slide

  43. 43
    compliment:
    ➡️

    View Slide

  44. 44
    ➡️
    travel_toward:

    View Slide

  45. 45
    murder:
    !
    !
    ➡️

    View Slide

  46. 46
    loot:
    ➡️

    View Slide

  47. 47

    View Slide

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

    View Slide

  49. 49

    View Slide

  50. 50

    View Slide

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

    View Slide

  52. 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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  57. 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)

    View Slide

  58. 58
    x3 : s(romeo)
    x2 : r
    let x3 = rule x0 x1

    rule2 :
    r * s(C) -o t(C) * u

    View Slide

  59. 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

    View Slide

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

    View Slide

  61. 61
    A -o B C -o D

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  65. 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

    View Slide

  66. 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

    View Slide

  67. 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

    View Slide

  68. 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

    View Slide

  69. 69
    program traces are!
    causally-structured stories

    View Slide

  70. 70
    Outline:

    !
    1. Background: forms of narrative play

    2. Extended example: Shakespeare World

    3. Ongoing work: playable specifications

    View Slide

  71. 71
    3. ONGOING WORK:

    PLAYABLE SPECIFICATIONS

    View Slide

  72. 72
    accessible tools for making

    games

    View Slide

  73. 73
    PuzzleScript

    View Slide

  74. 74

    View Slide

  75. 75

    View Slide

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

    View Slide

  77. 77
    Idea:

    Replace nondeterminism in the system

    with human interactor choice.

    View Slide

  78. 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).

    View Slide

  79. 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).

    View Slide

  80. 80
    CEPTRE

    3 additions to the core language:

    !
    sensing predicates

    acting predicates

    stages

    View Slide

  81. 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

    View Slide

  82. 82
    ONGOING/FUTURE WORK

    View Slide

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

    View Slide

  84. 84
    emergent systems have lots of corner cases

    =>

    bugs!

    View Slide

  85. 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?

    View Slide

  86. 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?

    View Slide

  87. 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))

    View Slide

  88. 88
    CONCLUSION

    View Slide

  89. 89
    Method:

    Linear logic programming + proof theory

    !
    Results:

    1. Structured narrative generation

    2. Playable narratives and game sketches

    View Slide

  90. 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.

    View Slide

  91. 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!

    View Slide

  92. Extra Slides
    92

    View Slide

  93. 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?

    View Slide

  94. 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)

    View Slide

  95. 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)

    View Slide

  96. 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!)

    View Slide

  97. 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?

    View Slide