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

Cabbages, Goat, and Wolf In Two Styles!!

Cabbages, Goat, and Wolf In Two Styles!!

Jason Orendorff

January 11, 2021
Tweet

More Decks by Jason Orendorff

Other Decks in Programming

Transcript

  1. Wolf,
    Goat, &
    Cabbages
    in two styles!!

    View Slide

  2. Wolf,
    Goat, &
    Cabbages
    in two styles!!
    Jason Orendorff
    !!Con West 2020

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. X

    View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. X

    View Slide

  15. dagnabbit
    X

    View Slide

  16. Wolf,
    Goat, &
    Cabbages
    in two styles!!

    View Slide

  17. Wolf,
    Goat, &
    Cabbages
    in two styles!!
    Jason Orendorff
    !!Con West 2020

    View Slide

  18. View Slide

  19. Book One -

    View Slide

  20. Book One - Inform 7

    View Slide

  21. Chapter 1 - The River
    The East Riverbank is a room.

    View Slide

  22. Chapter 1 - The River
    The East Riverbank is a room. “Here a
    lazy river crosses your path.”

    View Slide

  23. Chapter 2 - The Boat

    View Slide

  24. Chapter 2 - The Boat
    The boat is an enterable container in the
    East Riverbank. “A little boat is tied to
    the dock.”

    View Slide

  25. Chapter 3 - The Treasures
    A treasure is a kind of thing.

    View Slide

  26. Chapter 3 - The Treasures
    A treasure is a kind of thing.
    A wolf is in the East Riverbank. […]

    View Slide

  27. Chapter 3 - The Treasures
    A treasure is a kind of thing.
    The wolf, the goat, and the cabbages are
    treasures.
    A wolf is in the East Riverbank. […]

    View Slide

  28. View Slide

  29. DIVIDE FORCE BY MASS GIVING ACC.
    Given a book of macabre poetry is in my cart
    When I click "Buy"
    Then I should see "Checkout"
    COBOL (1959)
    Gherkin (2008)
    AppleScript (1993)
    tell application "Preview" to open "manual.pdf"
    activate application "Preview"

    View Slide

  30. A treasure is a kind of thing.
    The wolf, the goat, and the cabbages are
    treasures.
    A wolf is in the East Riverbank. […]

    View Slide

  31. A treasure is a kind of thing.
    The wolf, the goat, and the cabbages are
    treasures.
    A wolf is in the East Riverbank. […]

    View Slide

  32. A treasure is a kind of thing.
    The wolf, the goat, and the cabbages are
    treasures.
    A wolf is in the East Riverbank. […]

    View Slide

  33. A treasure is a kind of thing.
    The wolf, the goat, and the cabbages are
    treasures.
    A wolf is in the East Riverbank. […]

    View Slide

  34. The boat is an enterable container in the
    East Riverbank.

    View Slide

  35. The boat is an enterable container in the
    East Riverbank.

    View Slide

  36. View Slide

  37. East Riverbank
    Here a lazy river crosses your path.
    A boat is tied to a dock nearby.
    The "sheep" you bought at the fair is here.
    Your goat stands nearby, chewing on nothing in particular.
    >

    View Slide

  38. East Riverbank
    Here a lazy river crosses your path.
    A boat is tied to a dock nearby.
    The "sheep" you bought at the fair is here.
    Your goat stands nearby, chewing on nothing in particular.
    > drop the cabbages
    Dropped.
    > take goat
    Taken.
    >

    View Slide

  39. Instead of taking the boat, say “There’s
    no point carrying a boat around.”

    View Slide

  40. >

    View Slide

  41. > pick up the river

    View Slide

  42. That’s hardly portable.
    > pick up the river
    >

    View Slide

  43. That’s hardly portable.
    > pick up the river
    > take the goat

    View Slide

  44. You already have that.
    That’s hardly portable.
    > pick up the river
    > take the goat
    >

    View Slide

  45. You already have that.
    That’s hardly portable.
    > pick up the river
    > take the goat
    > pick myself up

    View Slide

  46. You are always self-possessed.
    You already have that.
    That’s hardly portable.
    > pick up the river
    > take the goat
    > pick myself up

    View Slide

  47. Carry out crossing:
    if the wolf and the goat are ashore together:
    say “…”;
    end the story saying “Someone has
    got your goat”;
    else if the goat and the cabbages… :

    otherwise:
    move the boat to the other bank.

    View Slide

  48. View Slide

  49. • The manual is amazing

    View Slide

  50. • The manual is amazing
    • “Use the serial comma.”

    View Slide

  51. Book Two -

    View Slide

  52. Book Two - Alloy

    View Slide

  53. class Person {
    loves: set Person
    }

    View Slide

  54. class Person {
    loves: set Person
    }

    View Slide

  55. sig Person {
    loves: set Person
    }

    View Slide

  56. sig Person {
    loves: set Person
    }
    Lin = new Person

    View Slide

  57. sig Person {
    loves: set Person
    }
    Lin = new Person

    View Slide

  58. View Slide

  59. Sig Person {
    loves: set Person
    }
    run {} for 3

    View Slide

  60. View Slide

  61. View Slide

  62. View Slide

  63. Person A loves Person B
    Balin → Dwalin
    Óin → Glóin
    Bombur → Balin
    Bombur → Glóin
    Bombur → Bombur

    View Slide

  64. Balin .loves = { Dwalin }
    Óin .loves = { Glóin }
    Bombur.loves = { Balin,
    Glóin,
    Bombur }

    View Slide

  65. View Slide

  66. sig Person {
    loves: set Person
    }

    View Slide

  67. sig Person {
    loves: set Person
    }
    Love relates various people
    to various people.

    View Slide

  68. sig Person {
    loves: set Person
    }
    Love relates various people
    to various people.
    The verb to love means the love relation.

    View Slide

  69. View Slide

  70. some Bombur.loves
    If Bombur loves anyone…
    Bombur.loves
    everyone loved by Bombur
    Bombur.~loves
    everyone who loves Bombur
    Bombur.loves = Person
    Everyone loves Bombur.

    View Slide

  71. Part SR1 - The Physical World Model
    The verb to contain means the containment relation.
    The verb to be in means the reversed containment relation.
    The verb to carry means the carrying relation.
    The verb to hold means the holding relation.
    The verb to wear means the wearing relation.

    View Slide

  72. Part SR1 - The Physical World Model
    The verb to contain means the containment relation.
    The verb to be in means the reversed containment relation.
    The verb to carry means the carrying relation.
    The verb to hold means the holding relation.
    The verb to wear means the wearing relation.

    View Slide

  73. sig Person {
    loves: set Person
    }

    View Slide

  74. sig Object {
    loves: set Object
    }

    View Slide

  75. sig Object {
    eats: set Object
    }

    View Slide

  76. sig Object {
    eats: set Object
    }
    sig Wolf extends Object {}
    sig Goat extends Object {}
    sig Cabbages extends Object {}
    sig Boat extends Object {}

    View Slide

  77. abstract sig Object {
    eats: set Object
    }
    one sig Wolf extends Object {}
    one sig Goat extends Object {}
    one sig Cabbages extends Object {}
    one sig Boat extends Object {}

    View Slide

  78. View Slide

  79. fact foodWeb {
    eats = (Wolf -> Goat)
    + (Goat -> Cabbages)
    }

    View Slide

  80. View Slide

  81. View Slide

  82. sig Riverbank {}

    View Slide

  83. View Slide

  84. sig Snapshot {
    }

    View Slide

  85. sig Snapshot {
    location: Object -> one Riverbank
    }

    View Slide

  86. // first, last, prev, next
    open util/ordering[Snapshot]
    sig Snapshot {
    location: Object -> one Riverbank
    }

    View Slide

  87. View Slide

  88. fact twoSidesToEveryRiver {
    #Riverbank = 2
    }

    View Slide

  89. View Slide

  90. fact beginningAndEnd {
    }

    View Slide

  91. fact beginningAndEnd {
    }
    one first.location[Object]

    View Slide

  92. fact beginningAndEnd {
    }
    one first.location[Object]
    one last.location[Object]

    View Slide

  93. fact beginningAndEnd {
    }
    one first.location[Object]
    one last.location[Object]
    first.location[Boat] != last.location[Boat]

    View Slide

  94. View Slide

  95. View Slide

  96. Why Alloy?

    View Slide

  97. View Slide

  98. https://playfic.com/games/jorendorff/cabbages

    View Slide