Programming Interactive Worlds with Linear Logic

B6ff5f798c18a3367b2770aa3ada0730?s=47 Chris
August 31, 2015

Programming Interactive Worlds with Linear Logic

Ph.D. thesis defense

B6ff5f798c18a3367b2770aa3ada0730?s=128

Chris

August 31, 2015
Tweet

Transcript

  1. 1

  2. 2

  3. 3 Attack (Starts at 1) Health (Starts at 3)

  4. 4 Buff: Add 1 to attack

  5. 5 Attack: Enemy subtracts your attack from their health

  6. 6 Yellow Team Go! BUFF ATTACK

  7. 7 Buff other: Spend your turn to increase someone else’s

    attack
  8. 8 Blue Team Go! BUFF (self or other) ATTACK

  9. 9

  10. 10

  11. 11

  12. 12 PROBLEM

  13. 13 Formal Language for Game Sketching Executable Rules First Platform-agnostic

    General
  14. 14 Formal Language for Game Sketching Executable Rules First Platform-agnostic

    General
  15. 15 Formal Language for Game Sketching Executable Rules First Platform-agnostic

    General
  16. 16 Formal Language for Game Sketching Executable Rules First Platform-agnostic

    General
  17. 17 Interactive Worlds (Definition) An interactive world is an initial

    configuration (e.g. your cards at the start of the game) ! together with rules for evolving configurations, (e.g.: buffing increases your attack) ! some of which are mediated by human interaction, randomness, or other processes.
  18. 18

  19. 19 A formal language for describing interactive worlds makes it

    easier to sketch and invent novel game & story designs. Thesis Statement (Take 1)
  20. 20 Thesis Statement (Take 1) A formal language for describing

    interactive worlds makes it easier to sketch and invent novel game & story designs.
  21. 21 Authoring Potential Narratives [Diagram credit: Sam Kabo Ashwell]

  22. 22 Authoring Potential Narratives

  23. 23 Authoring Potential Narratives choose character stats branch on character

    stats
  24. 24 A formal language for describing interactive worlds enables rapid

    prototyping of experimental game designs and deeper understanding of narrative structure. Thesis Statement (Take 2)
  25. 25 Thesis Statement (Take 2) A formal language for describing

    interactive worlds enables rapid prototyping of experimental game designs and deeper understanding of narrative structure.
  26. 26 THESIS STATEMENT Using linear logic to model interactive worlds

    enables rapid prototyping of experimental game designs and deeper understanding of narrative structure.
  27. Programming language (Ceptre) Causal analysis for games & narratives Case

    studies Meta-reasoning methodology 27 Contributions
  28. 28 Programming language (Ceptre) Causal analysis for games & narratives

    Case studies Meta-reasoning methodology Contributions
  29. 29 APPROACH Linear Logic Programming

  30. 30 Logic Facts about the world are propositions: ! The

    player is in the foyer Juliet loves Romeo Roger has 2 health points
  31. 31 Facts about the world are propositions: ! ! !

    Logic
  32. 32 Action and Change

  33. 33 Action and Change [Girard 1987, Girard/LaFont 87, Chang et

    al. 2003]
  34. 34

  35. 35

  36. 36 Movement rule, take 2

  37. 37

  38. 38

  39. 39 Movement rule, take 3

  40. 40 Movement rule, take 3’

  41. 41 Program Rules move : in player Room * adjacent

    Room Room’ —o in player Room’. ! adjacent/foyer-kitchen : adjacent foyer kitchen.
  42. 42 Author-defined terms and predicates, quantified Variables, tensor (*), bang

    (!), and lolli (—o) are all we need to specify action & change on a logical level. Linear Logic
  43. 43 A * $B —o C ! == ! A

    * B —o C * B Derived Syntax
  44. 44 Programming language (Ceptre) Causal analysis for games & narratives

    Case studies Meta-reasoning methodology Contributions
  45. 45 Linear Logic Programming Configuration (linear context) term/predicate declarations,
 permanent

    facts, and rules [Harland et al. 2000; Lopez et al. 2005] e.g. Signature (permanent rules)
  46. 46 Multiset Rewriting [Cervesato & Scevdrov 2009] (synonym: forward chaining)

  47. 47 EXAMPLE WORLD: Defense Defense

  48. 48 Buffing buff : turn Player * attack Player Att

    -o attack Player (Att + 1).
  49. 49 Buffing Others buff : turn Player * attack Player’

    Att -o attack Player’ (Att + 1).
  50. attack : turn Player * $attack Player A * health

    Enemy H -o health Enemy (H - A). ! die : health P 0 -o dead P. 50 Attacking
  51. 51 Configurations (Contexts) { turn player1, turn player4, […], on_team

    player1 blue, on_team player2 yellow, health player1 3, attack player2 2, […] } Multisets of ground propositions
  52. 52 Running a program context init = {…} #trace init.

    0
  53. 53 Running a program Quiescence: no more rules in can

    fire 0 … n
  54. 54 Prior linear logic programming languages: Celf, LolliMon, Lygon Ceptre:

    Adding Interactivity and Stages
  55. 55 stage yellow_team = { attack : … buff :

    … } ! stage blue_team = { attack : … buff : … }
  56. 56 stage play = { attack : … buff :

    … } ! stage generate_turns = { … }
  57. 57 stage play = { attack : … buff :

    … } ! qui * stage play * team_turn T * opp T T’ -o stage generate_turns * team_turn T. ! stage generate_turns = { … } ! qui * stage generate_turns -o stage play.
  58. 58 stage play = { attack : … buff :

    … } #interactive play. ! ! ! stage generate_turns = { … }
  59. 59 0: (quiesce) 1: (buff chris 1) 2: (buff andre

    1) […] 7: (target chris yellow blue frank 1 3) 8: (target chris yellow blue gwenn 1 3) ! ?-
  60. 60 Ceptre Persistent backward-chaining Linear forward-chaining Terms, predicates Stages and

    quiescence rules (Sensing and acting predicates) http://www.github.com/chrisamaphone/interactive-lp Chapter 4 - AIIDE 2015
  61. 61 Ceptre Compilable to Celf via interleaved (linear) backward and

    forward chaining http://www.github.com/chrisamaphone/interactive-lp Chapter 4 - AIIDE 2015
  62. Programming language (Ceptre) Causal analysis for games & narratives Case

    studies Meta-reasoning methodology 62 Contributions
  63. 63 63 Proof Construction

  64. 64 64

  65. 65 65

  66. 66 66

  67. 67 67

  68. 68 68

  69. 69 Concurrent Structure let b = r1 a1 let c

    = r2 a2 a1 a2 = b c let b = r1 a1 let c = r2 a2
  70. 70 Concurrent Structure r1 c r2 b a1 a2

  71. 71 Causal Structure attack buff die buff

  72. 72 TAKEAWAY: Concurrent structure in proofs yields causal structure among

    actions [Bosser et al. 2010, 2011; Watkins et al. 2002]
  73. Programming language (Ceptre) Causal analysis for games & narratives Case

    studies Meta-reasoning methodology 73 Contributions
  74. 74 Case Study: Shakespearean Tragedy Story World do/becomeSuicidal : at

    C L * depressed C * depressed C * depressed C * depressed C -o at C L * suicidal C * wants C weapon.
  75. 75 Causal Structure do/murder romeo capulet town do/insult/private tybalt town

    montague do/becomeSuicidal montague town do/m juliet tow do/suicide romeo town x147 do/mourn montague town romeo x154 x153 x152 x151 x155 x182 x188 x187 x186 x185 x184 x198 x197 x196 x200 x199
  76. 76 init emmaSpendsYearsInCovent leonFallsInLove emmaReadsRomanticNovels emmaReadsRomanticNovels emmaMarriesCharles emmaInvitedToBall emmaDiscoversLeonsLove emmaPushesLeonAway

    emmaContractsDebts emmaDoesNotGoToBall rodolpheDecidesToSeduceEmma emmaAcceptsRodolpheAdvances emmaContractsDebts rodolpheRelationshipFalters charlesDecidesToOperateHypolyte hypolyteIsAmputated emmaPurchasesGift emmaOffersGift emmaPurchasesProstheticLeg rodolpheBreaksUp emmaJumpsThroughWindow OR Causal Structure
  77. 77 Narrative Generation Chapter 3/INT 2014/LPNMR 2013

  78. 78

  79. 79 Tamara

  80. 80 Tamara

  81. 81 ! b9_aelis_monologue : aelis b9 diningroom -o aelis c12

    atrium. ! b10_dante_despiga : dante b10 atrium * despiga b10 atrium -o dante c12 atrium * despiga c12 atrium. ! b11_dannunzio_luisa : dannunzio b11 dannunzioroom * luisa b11 dannunzioroom -o dannunzio c12 atrium * luisa c12 above-atrium.
  82. 82 x12 a1_dannunzio_exits x17 x16 a1_grp2_aelis b4_carlotta_kisses_finzi x20 x19 x18

    b2_despiga_monologue a1_grp1_luisa x22 x21 b9_aelis_monologue a1_grp2_emilia x23 b10_dante_despiga x25 x24 b3_luisa_monologue a1_grp1_dannunzio x2 x26 x27 c12_finzi_exit x28 b11_dannunzio_luisa x30 a1_emilia_exits x32 x31 b6_dannunzio_monologue x33 x34 x36 x35 x37 x39 x38 b7_emilia_monologue x41 x40 x42 b8_emilia_carlotta x44 x43 b5_finzi_monologue x46 x45 x47 x53 x51
  83. 83 a1_emilia_exits a1_dannunzio_exits x14 a1_grp1_dannunzio x16 a1_grp2_emilia b2_despiga_monologue a1_grp2_aelis a1_grp1_luisa

    x23 b10_dante_despiga x25 x24 b3_luisa_monologue x28 x27 b6_dannunzio_monologue x30 x29 c12_finzi_exit x31 b11_dannunzio_luisa x32 b4_carlotta_kisses_finzi x35 x34 b9_aelis_monologue x36 x38 x37 b7_emilia_monologue x39 x41 x40 c_final x43 x42 b8_emilia_carlotta b5_finzi_monologue x44 x45 x47 x46 c12_gunshot x53 x52 x51 x50 x49 x48 c12_emilia_carlotta_aelis_luisa_leave_atrium c12_take_presents_to_leda x56 x55 x54 c13_finzi_luisa_confrontation x60 x59 x58 x57 c13_emilia_aelis_carlotta_luisa_sidehall x62 x61 x66 x65 x64 x63 x70 x69 x68 x67 c14_emilia_enter_leda x74 x73 x72 x71 c14_all_exit_leda x78 x77 x76 x75
  84. 84 Interactive World Case Studies Chapter 5 Interactive storytelling (BuffyWorld)

    Action/reaction model ! ! ! !
  85. 85 Interactive World Case Studies Chapter 5 Interactive storytelling (BuffyWorld)

    Action/reaction model ! Board/card games: die rolls and distribution ! !
  86. 86 Interactive storytelling (BuffyWorld) Action/reaction model ! Board/card games: die

    rolls and distribution ! Novel designs: generative simulation games (RPG and GardenSim worlds) Interactive World Case Studies Chapter 5
  87. 87 Limitations? Negation Comprehension Rule ordering etc.

  88. 88 Limitations? Programming Tricks (see Chapter 4) Negation Comprehension Rule

    ordering etc.
  89. 89 Fun with Ceptre Debugging automatic/generative stages Experimenting with player

    control schemes
  90. 90 Fun with Ceptre “Fuzz testing” player input Augmenting rules

    w/AI strategies
  91. buff : turn Player * $on_team Player T * $on_Team

    Player’ T * attack Player’ Att -o attack Player’ (s Att). 91 Augmenting rules with strategies: Buffing Only Friends
  92. attack : turn Player * $on_team Player Team * opp

    Team Team’ * $on_team Enemy Team’ * $attack Player Att * health Enemy H -o subtract Enemy H Att. 92 Augmenting rules with strategies: Attacking Only Enemies
  93. 93 Fun with Ceptre Evaluating for Balance

  94. 94 (Actual) Limitations buff : turn Player * attack Player

    A -o attack Player (A+1). Invariants: each player should only ever have 1 turn active ! a character should either be dead or have a team ! a character with a team should always have an attack value ! …
  95. 95 Contributions Programming language (Ceptre) Causal analysis for games &

    narratives Case studies Meta-reasoning methodology
  96. 96 (Chapter 6) Reasoning Framework

  97. 97 Program Invariants INV holds of all initial configurations; !

    and for all rules and all contexts , ! whenever INV holds of sdfa ! ! INV holds of j Invariant INV holds for a specification iff:
  98. 98 Propositional Ceptre (similar to Horn clauses): ! ! !

    where can be atoms a or !a. Program Invariants
  99. 99 Generative invariants (Simmons ’12) Program Invariants = =

  100. 100 Decidability Result Via vector addition systems, the problem can

    be reduced to Presburger arithmetic (known decidable.) Upshot: Whether or not a given (propositional Ceptre) program satisfies a flat invariant is decidable.
  101. 101 DISCUSSION

  102. 102 To PL theory: Better understanding of forward-chaining logic programming

    Theoretical result about checking properties of evolving systems Large base of application examples ! To game & narrative design: Better understanding of structure for potential narratives Unification of rule languages for narratives and systems Sandbox for prototyping, analyzing, and iterating upon designs Thesis Contributions
  103. 103 Future Work Narrative representation: modal and higher-order logics (character-based

    reasoning about other characters’ beliefs; theory of mind) ! Automated reasoning tools ! Accessible game design framework
  104. 104 Thesis Statement, reprise Ceptre (Ch 4) Reasoning Tools (Ch

    6) Using linear logic to model interactive worlds enables rapid prototyping of experimental game designs and deeper understanding of narrative structure.
  105. 105 Thesis Statement, reprise Using linear logic to model interactive

    worlds enables rapid prototyping of experimental game designs and deeper understanding of narrative structure. Case Studies (Ch 5)
  106. 106 Thesis Statement, reprise Chapters 2 & 3 Using linear

    logic to model interactive worlds enables rapid prototyping of experimental game designs and deeper understanding of narrative structure.
  107. Thanks! Using linear logic to model interactive worlds enables rapid

    prototyping of experimental game designs and deeper understanding of narrative structure. Thesis Statement, reprise http://www.cs.cmu.edu/~cmartens/thesis.pdf
  108. 108 Bonus Slides

  109. 109 Backward chaining (goal directed) ! vs ! Forward chaining

    (context-directed)
  110. 110 Backward Chaining

  111. 111 Backward Chaining

  112. 112 Backward Chaining

  113. 113 Forward Chaining

  114. 114 Forward Chaining

  115. 115 Forward Chaining

  116. 116 Forward Chaining

  117. attack : turn Player * $on_team Player Team * opp

    Team Team’ * $on_team Enemy Team’ * $attack W Att * health Enemy H * nat_minus H Att H’ -o health Enemy H’. ! die : health P z -o dead P. 117 Backward-Chaining Subtraction
  118. 118 } Prove with goal-directed rules } Find in linear

    context attack : turn Player * $on_team Player Team * $on_team Enemy Team’ * $attack W Att * health Enemy H * opp Team Team’ * nat_minus H Att H’ -o health Enemy H’.
  119. 119 attack : turn Player * $attack W Att *

    health Enemy H -o subtract Enemy H Att. Attacking
  120. 120 subtract/s : subtract P (s Health) (s Att) -o

    subtract P Health Att. ! subtract/done : subtract P H z -o health P H. ! subtract/die : subtract P z Att -o dead P. Forward-Chaining Subtraction
  121. 121 nat_minus nat nat nat : bwd. minus/z- : nat_minus

    z N z. minus/-z : nat_minus N z N. minus/s : nat_minus (s N) (s M) P <- nat_minus N M P. Backward-Chaining Subtraction
  122. opp team team : bwd. opp blue yellow. opp yellow

    blue. 122 Persistent Predicates
  123. 123 Types and Predicates team : type. blue : team.

    yellow : team. ! player : type. ! on_team player team : pred. health player nat : pred. attack player nat : pred.
  124. 124 Types and Predicates nat : type. z : nat.

    s nat : nat. (Operators on numbers can be defined in the language via backward chaining, or by accessing built-in functions.)
  125. 125

  126. 126 PROBLEM 2: Feature Creep

  127. 127 Interactive Fiction (IF)

  128. 128 Interactive Fiction (IF)

  129. 129 Twine Graph + hidden state

  130. 130 Forward Chaining

  131. 131 A formal language for describing stories and games makes

    it easier to sketch and invent novel designs. Thesis Statement (Take 1)
  132. 132 Thesis Statement (Take 1) A formal language for describing

    stories and games makes it easier to sketch and invent novel designs.