Ceptre: A Language for Modeling Interactive Worlds

B6ff5f798c18a3367b2770aa3ada0730?s=47 Chris
September 24, 2015
120

Ceptre: A Language for Modeling Interactive Worlds

Slides for Future Programming Workshop at Strange Loop

B6ff5f798c18a3367b2770aa3ada0730?s=128

Chris

September 24, 2015
Tweet

Transcript

  1. 1 CEPTRE A Language for Modeling Interactive Worlds Chris Martens

    Future Programming Workshop @ Strange Loop September 24, 2015
  2. 2 CEPTRE A Language for Modeling Interactive Worlds Chris Martens

    Future Programming Workshop @ Strange Loop September 24, 2015
  3. 3 Attack (Starts at 1) Health (Starts at 3) Defense

    Defense
  4. 4 Buff: Add 1 to attack

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

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

    attack
  7. 7 BUFF (self or other) ATTACK

  8. 8

  9. 9

  10. 10

  11. 11 PROBLEM

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

    General
  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

  17. 17

  18. 18 Interactive Worlds An interactive world is an initial configuration

    (e.g. players’ stats at the start of the game) ! together with rules for evolving configurations, (e.g.: buffing increases player’s attack) ! some of which are mediated by human interaction, randomness, or other processes.
  19. 19 CEPTRE ! PAYOFF ! DISCUSSION Outline

  20. 20 CEPTRE Linear Logic Programming Stages & Interaction ! PAYOFF

    ! DISCUSSION Outline
  21. 21 Logic Facts about the world are propositions: ! The

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

    Logic
  23. 23 Action and Change

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

    al. 2003]
  25. 25

  26. 26

  27. 27 Movement rule, take 2

  28. 28

  29. 29

  30. 30 Movement rule, take 3

  31. 31 Movement rule, take 3’

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

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

    * B —o C * B Derived Syntax
  35. 35 LANGUAGE (Logic Programming)

  36. 36 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)
  37. 37 Multiset Rewriting [Cervesato & Scevdrov 2009] (synonym: forward chaining)

  38. 38 EXAMPLE WORLD: Defense Defense

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

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

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

    Enemy H -o health Enemy (H - A). ! die : health P 0 -o dead P. 41 Attacking
  42. 42 Configurations (Contexts) context init = { on_team chris blue,

    on_team gwenn yellow, health chris 3, attack gwenn 2, […] } Multisets of ground propositions
  43. 43 Traces buff : […] attack : […] die :

    […] ! ! context init = {…} ! ! #trace init. } } 0
  44. 44 Running a program Quiescence: no more rules in can

    fire 0 … n
  45. 45 Interactivity? #interactive. #trace init.

  46. 46 Interactivity? 1: (buff gwenn chris (s z)) 2: (buff

    gwenn karl (s z)) […] 17: (target chris (s z) gwenn (s (s (s z))) (s (s z))) 18: (target chris (s z) chris (s (s (s z))) (s (s z))) ?-
  47. 47 Interactivity? 1: (buff gwenn chris (s z)) 2: (buff

    gwenn karl (s z)) […] 17: (target chris (s z) gwenn (s (s (s z))) (s (s z))) 18: (target chris (s z) chris (s (s (s z))) (s (s z))) ?- yellow team blue team
  48. 48 CEPTRE Linear Logic Programming Stages & Interaction ! PAYOFF

    ! DISCUSSION Outline
  49. 49 CEPTRE Linear Logic Programming Stages & Interaction ! PAYOFF

    ! DISCUSSION Outline
  50. 50 heads_wins : heads * tails -o heads. tails_wins :

    heads * tails -o tails. ! overall_heads : heads -o heads_overall. overall_tails : tails -o tails_overall.
  51. 51 heads_wins : $stage tournament * heads * tails -o

    heads. ! tails_wins : $stage tournament * heads * tails -o tails. ! ! ! overall_heads : $stage tally * heads -o heads_overall. overall_tails : $stage tally * tails -o heads_overall.
  52. 52 heads_wins : $stage tournament * heads * tails -o

    heads. ! tails_wins : $stage tournament * heads * tails -o tails. ! [???] stage tournament -o stage tally. ! overall_heads : $stage tally * heads -o heads_overall. overall_tails : $stage tally * tails -o heads_overall.
  53. 53 heads_wins : $stage tournament * heads * tails -o

    heads. ! tails_wins : $stage tournament * heads * tails -o tails. ! qui * stage tournament -o stage tally. ! overall_heads : $stage tally * heads -o heads_overall. overall_tails : $stage tally * tails -o heads_overall.
  54. 54 stage tournament = { heads_wins : heads * tails

    -o heads. tails_wins : heads * tails -o tails. } ! qui * stage tournament -o stage tally. ! stage tally = { overall_heads : heads -o heads_wins. overall_tails : tails -o tails_wins. }
  55. 55 stage tournament = { heads_wins : heads * tails

    -o heads. tails_wins : heads * tails -o tails. } #interactive tournament. ! qui * stage tournament -o stage tally. ! stage tally = { overall_heads : heads -o heads_wins. overall_tails : tails -o tails_wins. }
  56. 56 BUFF (self or other) ATTACK Returning to Defense Defense…

  57. 57 Ceptre User-defined terms, predicates Multiset rewriting rules Prolog-style rules

    Stages, quiescence, and interactivity http://www.github.com/chrisamaphone/interactive-lp
  58. 58 Limitations? Negation Comprehension Rule ordering etc.

  59. 59 Limitations? Programming Tricks (See: Chapter 4 of my thesis)

    Negation Comprehension Rule ordering etc.
  60. 60 Credits ! Prior linear logic programming languages: Lygon [1996],

    LolliMon [2005], Celf [2008] ! Ceptre adds interactivity and stages.
  61. CEPTRE ! PAYOFF Case Studies Experiments ! DISCUSSION 61 Outline

  62. 62 Case Studies Narrative Generation Multi-agent interactive social simulation Roguelike-likes

    (combat & monster gen) Board games (Settlers of Catan)
  63. 63 “Fuzzing” player input & augmenting rules w/AI strategies Ceptre

    as Game Chemistry Lab
  64. buff : turn Player * $on_team Player T * $on_Team

    Player’ T * attack Player’ Att -o attack Player’ (s Att). 64 Augmenting rules with strategies: Buffing Only Friends
  65. 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. 65 Augmenting rules with strategies: Attacking Only Enemies
  66. 66 Evaluating for Balance

  67. 67 Evaluating for Balance (c.f. LUDI system for game synthesis

    & evaluation)
  68. 68 CEPTRE ! PAYOFF ! DISCUSSION Invariants Future Work Lessons

    Outline
  69. 69 (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 should always have an attack value ! …
  70. 70 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:
  71. 71 Generative invariants (Simmons ’12) Program Invariants = =

  72. 72 Decidability Result Whether or not a given (propositional Ceptre)

    program satisfies an invariant is decidable. n.b.: O(2^(2^n)) Not a tractable checking algorithm! Future work: automation & integration into the PL.
  73. 73 Future Work Accessible game design frameworks Ceptre Program Hypertext

    front-end 2D tile front-end Twine output PuzzleScript output
  74. 74 Lessons for ! PL Design

  75. 75 Lessons for Domain-Specific? PL Design

  76. 76 Lessons for Domain-Oriented PL Design

  77. The Curry-Howard homeomorphism LC'90 77 Logical Basis

  78. 78 Minimalism

  79. 79 Revisionism

  80. Thanks! Ceptre: github.com/chrisamaphone/interactive-lp ! Me: Chris Martens Web: http://www.cs.cmu.edu/~cmartens Thesis:

    [Web]/thesis Twitter: @chrisamaphone Research Blog: lambdamaphone.blogspot.com 80
  81. Bonus Slides 81

  82. Backward chaining (goal directed) ! vs ! Forward chaining (context-directed)

    82
  83. Backward Chaining 83

  84. Backward Chaining 84

  85. Backward Chaining 85

  86. Forward Chaining 86

  87. Forward Chaining 87

  88. Forward Chaining 88

  89. Forward Chaining 89

  90. } 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’. 90
  91. attack : turn Player * $attack W Att * health

    Enemy H -o subtract Enemy H Att. Attacking 91
  92. 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 92
  93. 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 93
  94. opp team team : bwd. opp blue yellow. opp yellow

    blue. Persistent Predicates 94
  95. Types and Predicates team : type. blue : team. yellow

    : team. ! player : type. ! on_team player team : pred. health player nat : pred. attack player nat : pred. 95
  96. 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.) 96
  97. 97 stage yellow_team = { attack : … buff :

    … } ! stage blue_team = { attack : … buff : … } Returning to Defense Defense…
  98. 98 stage play = { attack : … buff :

    … } ! stage generate_turns = { … }
  99. 99 stage play = { attack : turn P *

    … buff : turn P * … } ! 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.
  100. 100 stage play = { attack : … buff :

    … } #interactive play. ! ! ! stage generate_turns = { … }
  101. Causal Analysis 101

  102. 102 Proof Construction 102

  103. 103 103

  104. 104 104

  105. 105 105

  106. 106 106

  107. 107 107

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

    r2 a2 a1 a2 = b c let b = r1 a1 let c = r2 a2 108
  109. Concurrent Structure r1 c r2 b a1 a2 109

  110. Causal Structure attack buff die buff 110

  111. do/genturns attack gwenn blue yellow chris (s (s z)) (s

    z) z buff_other chris yellow roger (s (s z)) x176 buff frank (s (s (s z))) do/gen_turn blue frank do/gen_turn blue gwenn x191 do/genturns another_round x192 x194 do/play x193 buff roger (s (s (s z))) x202 do/gen_gen_turns x201 x203 do/gen_turn yellow karl x208 x207 x206 x209 x211 switch_team_turn blue yellow x210 x214 x213 x212 do/gen_turn frank x217 x216 x215 do/restore_team gwenn blue do/gen_turn gwenn x221 x220 x219 x218 x223 x222 x224 x226 x227 x228 x233 x232 x231 die chris yellow x234 x238 x237 111
  112. Concurrent structure in proofs yields causal structure among actions 112

  113. 113