Implementing the example graph grammar from "Procedural Generation in Game Design"

in procjam •  6 years ago  (edited)

Dr. Joris Dormans wrote a chapter in "Procedural Generation in Game Design" (Tanya X. Short and Tarn Adams, editors) about cyclic generation, and he included this short example of a graph grammar on page 88:

Here it is translated into Soffit:

{
    "version" : "0.1",
    "start": "S->G; S[start]; G[goal]",
    
    "S->G; S[start]; G[goal]" :
    "S->A->G->B->S; S[start]; G[goal]",
    
    "X->Y; X[goal]" : [
        "X->Y; X->Lock->NewGoal; NewGoal[goal]; Y->Key[contains]; Key->Lock[unlocks]; Lock[lock]; Key[key];",
        "X->New->Y; X[goal]"
    ],

    "X->Y; X" :        "X->New->Y",
    "X->Y; X[start]" : "X->New->Y; X[start]"
}

Some differences:

  • I don't support wildcards yet, so his rule that extends the cycle got broken into three rules.
  • My system of attributes is simpler; I don't really allow multiple attributes per object, just a single tag. So I decided it was better to implement the lock as a separate node rather than an attribute on the path, and the key as a separate object rather than an attribute of the room.

Example output:

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!