Giter Site home page Giter Site logo

jschomay / elm-narrative-engine Goto Github PK

View Code? Open in Web Editor NEW
132.0 8.0 15.0 1.12 MB

A tool for building interactive fiction style stories in Elm.

Home Page: https://enegames.itch.io/elm-narrative-engine

License: Other

Elm 100.00%
elm-lang elm-narrative-engine interactive-fiction game-engine

elm-narrative-engine's Issues

Change DSL for building story rules?

I've given a lot of thought on the dsl for the story rules, and if you've seen my ElmConf presentation you know it went through a number of iterations.

However, I'm thinking of changing it one more time!

Reasons:

  • Get rid of infix notation
  • Add flexibility
  • Add clarity
  • Follow standard patterns

I really like Luke Westby's forward apply approach, and think it would work well, though it does have some implications on the design.

This is what it would look like:

myStoryRules =
    [ Story.rule
        |> onInteractionWith (location Hallway)
        |> when (inLocation Kitchen)
        |> moveTo Hallway
        |> narrate "You find a back door leading out..."
    ...
    ]

That would build up a record for a story rule of trigger, condition, commands and narration.

As nice as that is, it loses some constraints from how I have it currently:

  1. You can "chain" pieces together in any order, though that's really not a problem.
  2. You can omit pieces, which is fine too, it just means I need some reasonable defaults (no trigger matches every rule, no condition matches every rule, no changes does nothing, no narration gives default narration for the item interacted with.)
  3. You can duplicate pieces, which gets trickier. Multiple triggers would probably match if any of them matches, multiple conditions would probably match if all of them match, multiple changes would make all of those changes, and multiple narrations would be appended together (which is weird, but works).

Although these implications change some of the fundamental ways of thinking about story rules, I think they make sense and are even more expressive. One downside is losing the possibility to specify all or any when giving multiple whens. I don't see a clean way to add that to the dsl.

Thoughts?

For what it is worth, here are some other alternative approaches that I have considered, but don't like as much:

howItIsNow =
    [ interactingWith (location Hallway)
        `when` (inLocation Kitchen)
        `changesWorld` []
        `narrates` afraidOfHallway
    ]


rawRecord =
    [ { trigger = interactingWith (location Hallway)
      , condition = (inLocation Kitchen)
      , changes = []
      , narration = afraidOfHallway
      }
    ]


constrainedTuple =
    [ ( interactingWith (location Hallway)
      , when (inLocation Kitchen)
      , changesWorld []
      , narrates afraidOfHallway
      )
    ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.