Hacker News new | past | comments | ask | show | jobs | submit login

I made one in vanilla JS on canvas and was focused on making trees while keeping it fast as possible. If you add probability for each rule, you can get very close to real like trees. To handle probability faster, I simply added the rules with higher chance more number of times in the set. Then I started following The Book (ABOP). And what I stopped at was having the need to write a compiler for custom syntax and things that come with it.

If I don't dive into functions etc I got far enough with a loop iterating on ops, but it was getting tedious adding more functionality while following abop. Might sit and give another try, some day.




i feel like js is flexible enough that you can probably use an embedded dsl instead of writing a parser; maybe something like

    {
        a: '-bff+affa+ffb-',
        b: '+aff-bffb-ffa+',
        c: ['a', {p: .1}, 'b', {p: .9}],
    }


It's similar to this already. But this isn't flexible enough to implement methods etc which abop expands towards. My goal was to do almost everything all other browser based lsystems are doing while keeping it fast which most tools are not.


you'll probably be pleasantly surprised by how easy it is to write a parser using a parser generator; unfortunately i don't know which one to recommend for js (i've used yacc, ocamlyacc, hammer, and a few i've written myself, but i don't recommend using the js one i wrote)

if you aren't pleasantly surprised, maybe try a different parser generator




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: