First real Soffit examples

in procjam •  6 years ago  (edited)

I've gotten Soffit to the point where it can now produce interesting graphs, like this one:

full size

The rule set that produces this graph is:

{
    "version" : "0.1",
    "start" : "ROOT [color=maroon]",
    "X [color=maroon]" : "X[color=maroon]; Y[color=brown]; X--Y",
    "Y [color=brown]" : [ "Y [color=brown]; Z[color=green]; Y--Z",
                          "Y [color=brown]; Z[color=brown]; Y--Z",
                          "Y [color=forestgreen]; Z1[color=green]; Z2[color=green]; Y--Z1; Y--Z2;" ]
}

As you can see, the tags in this grammar are graphviz attributes, which are just copied into the output directly!

The numbers are the order in which new nodes were added to the graph.

I am thinking of adding an option to do a separate rewrite step, where you apply one grammar and then another, so that the first grammar can be written with "natural" tags like "root", "internal", "leaf" and then be rewritten in one pass to be display labels and attributes.

Getting closer to a release. All this is on github and available to play with right now, but to-do's include:

  • Write a tutorial
  • Look at how parsing errors are displayed
  • Figure out which characters to accept (and do so efficiently, startup time is still kind of long)
  • Friendlier command line, other output options besides SVG, ensure dependencies are correct
  • More options to control graph expansion (when to quit, for example? Time-based instead of number of iterations?)
  • Apply multiple rule sets (maybe in v2)
  • Weighting for rules (maybe in v3)
  • Add to PyPi? (maybe in a stable version)

Development blog entries

My #procjam project: Soffit
Soffit progress report #2
Soffit non-progress report #3
Hooray for unit tests
Soffit progress report #5
graphviz clusters suck
Graph rewrite examples, generated by Soffit

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:  
Loading...

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!

A simple expression rewrite:

{
    "start" : "A[+]; B[*]; X[exp]; Y[exp]; Z[exp]; B->A; B->X->C1; A->Y->C2; A->Z->C3; C1[17]; C2[34]; C3[19]; ",
    
    "M->P; M->A; P->B; P->C; P[+]; M[*]; A[exp]; B[exp]; C[exp];" :
    "M[+]; M1[*]; M2[*]; M->M1; M->M2; M1->A; M1->B; M2->A; M2->C; A[exp]; B[exp]; C[exp]"
}

Takes this:

To this:

Implementing the distributive law on an expression DAG.

Another graph generated by iterating a simple rule:

{
    "start" : "A--B",
    "A--B" : "A--C--B--D--A"
}

Congratulations @markgritter! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 250 as payout for your posts. Your next target is to reach a total payout of 500

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:

Be ready for the next contest!

Support SteemitBoard's project! Vote for its witness and get one more award!