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

Programming Interactive Worlds with Linear Logic

Chris
August 31, 2015

Programming Interactive Worlds with Linear Logic

Ph.D. thesis defense

Chris

August 31, 2015
Tweet

More Decks by Chris

Other Decks in Research

Transcript

  1. 1

  2. 2

  3. 9

  4. 10

  5. 11

  6. 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.
  7. 18

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

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

    interactive worlds makes it easier to sketch and invent novel game & story designs.
  10. 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)
  11. 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.
  12. 26 THESIS STATEMENT Using linear logic to model interactive worlds

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

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

    Case studies Meta-reasoning methodology Contributions
  15. 30 Logic Facts about the world are propositions: ! The

    player is in the foyer Juliet loves Romeo Roger has 2 health points
  16. 34

  17. 35

  18. 37

  19. 38

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

    Room Room’ —o in player Room’. ! adjacent/foyer-kitchen : adjacent foyer kitchen.
  21. 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
  22. 43 A * $B —o C ! == ! A

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

    Case studies Meta-reasoning methodology Contributions
  24. 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)
  25. attack : turn Player * $attack Player A * health

    Enemy H -o health Enemy (H - A). ! die : health P 0 -o dead P. 50 Attacking
  26. 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
  27. 55 stage yellow_team = { attack : … buff :

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

    … } ! stage generate_turns = { … }
  29. 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.
  30. 58 stage play = { attack : … buff :

    … } #interactive play. ! ! ! stage generate_turns = { … }
  31. 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) ! ?-
  32. 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
  33. 61 Ceptre Compilable to Celf via interleaved (linear) backward and

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

    studies Meta-reasoning methodology 62 Contributions
  35. 69 Concurrent Structure let b = r1 a1 let c

    = r2 a2 a1 a2 = b c let b = r1 a1 let c = r2 a2
  36. 72 TAKEAWAY: Concurrent structure in proofs yields causal structure among

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

    studies Meta-reasoning methodology 73 Contributions
  38. 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.
  39. 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
  40. 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
  41. 78

  42. 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.
  43. 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
  44. 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
  45. 85 Interactive World Case Studies Chapter 5 Interactive storytelling (BuffyWorld)

    Action/reaction model ! Board/card games: die rolls and distribution ! !
  46. 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
  47. 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
  48. 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
  49. 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 ! …
  50. 95 Contributions Programming language (Ceptre) Causal analysis for games &

    narratives Case studies Meta-reasoning methodology
  51. 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:
  52. 98 Propositional Ceptre (similar to Horn clauses): ! ! !

    where can be atoms a or !a. Program Invariants
  53. 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.
  54. 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
  55. 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
  56. 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.
  57. 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)
  58. 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.
  59. 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
  60. 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
  61. 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’.
  62. 119 attack : turn Player * $attack W Att *

    health Enemy H -o subtract Enemy H Att. Attacking
  63. 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
  64. 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
  65. opp team team : bwd. opp blue yellow. opp yellow

    blue. 122 Persistent Predicates
  66. 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.
  67. 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.)
  68. 125

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

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

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