Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Ceptre: A Language for Modeling Interactive Worlds

Chris
September 24, 2015
180

Ceptre: A Language for Modeling Interactive Worlds

Slides for Future Programming Workshop at Strange Loop

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

  4. 9

  5. 10

  6. 16

  7. 17

  8. 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.
  9. 21 Logic Facts about the world are propositions: ! The

    player is in the foyer Juliet loves Romeo Roger has 2 health points
  10. 25

  11. 26

  12. 28

  13. 29

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

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

    * B —o C * B Derived Syntax
  17. 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)
  18. attack : turn Player * $attack Player A * health

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

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

    […] ! ! context init = {…} ! ! #trace init. } } 0
  21. 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))) ?-
  22. 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
  23. 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.
  24. 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.
  25. 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.
  26. 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.
  27. 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. }
  28. 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. }
  29. 57 Ceptre User-defined terms, predicates Multiset rewriting rules Prolog-style rules

    Stages, quiescence, and interactivity http://www.github.com/chrisamaphone/interactive-lp
  30. 59 Limitations? Programming Tricks (See: Chapter 4 of my thesis)

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

    LolliMon [2005], Celf [2008] ! Ceptre adds interactivity and stages.
  32. 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
  33. 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
  34. 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 ! …
  35. 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:
  36. 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.
  37. 73 Future Work Accessible game design frameworks Ceptre Program Hypertext

    front-end 2D tile front-end Twine output PuzzleScript output
  38. 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
  39. } 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
  40. attack : turn Player * $attack W Att * health

    Enemy H -o subtract Enemy H Att. Attacking 91
  41. 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
  42. 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
  43. opp team team : bwd. opp blue yellow. opp yellow

    blue. Persistent Predicates 94
  44. 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
  45. 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
  46. 97 stage yellow_team = { attack : … buff :

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

    … } ! stage generate_turns = { … }
  48. 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.
  49. 100 stage play = { attack : … buff :

    … } #interactive play. ! ! ! stage generate_turns = { … }
  50. Concurrent Structure let b = r1 a1 let c =

    r2 a2 a1 a2 = b c let b = r1 a1 let c = r2 a2 108
  51. 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
  52. 113