Lindenmayer Systems: I made a thing

Monkey Forums/Monkey Programming/Lindenmayer Systems: I made a thing

SpaceAce(Posted 2014) [#1]
I got to goofing off with L-Systems (again) after a discussion on another forum. I hadn't done much with Monkey in a while, so I decided to use it for this project. If anyone is interested, I'll post the code, but I'll give you the same warning I gave the folks on the other forum: the code is embarrassingly bad. I have classes everywhere, weird logic, and lots of things done in ways they shouldn't have been done. I changed my mind about what I was doing a dozen times, and it shows.








There are more, but I don't want to cram this post too full of moving colors.


zoqfotpik(Posted 2014) [#2]
You're talking my language now. This is SWEET. L systems are incredibly powerful. Ever seen "The Algorithmic Beauty of Plants?" You might be interested in my sierpinski triangle toy if you have Blitzmax, it's over on the Blitzmax forum and uses recursive subdivision.

How long is your code? You should go over it one last time and put it up. I find that putting my code up makes me think about what I'm doing in ways that I wouldn't if I left it just for me.


SpaceAce(Posted 2014) [#3]
I'm glad someone digs this. I love this sort of thing. L-Systems are amazingly powerful given how trivial they are to implement.

I do have Blitzmax. I'll have a look at your code, it sounds interesting. I have not read the book you mentioned, but I did find another text that I cribbed some of the above systems from. I just did a quick search, and there's some cool stuff related to that book title, and I will definitely check it out.

The LSystem base class is maybe 200 lines, and the supporting code is a few dozen more. I extended the base class into a bunch of other classes (Sierpinski A and B, Koch Curve, and so on) for easy instantiation, but only a couple of those actually need classes of their own for additional functionality. Those classes total another 500 lines or so, but a lot of it is just overloads for the Create() method, because that's how I roll.

If this were interesting or useful for more people, I'd probably clean it up a bit and turn it loose, but it doesn't look like it sparked much interest.


itto(Posted 2014) [#4]
This looks interesting, I've never heard of them before. (Shame on me!) Do they find application in gaming except perhaps 3D rendering/modeling? I'm reading a bit about them, found the link for the PDF version of the book you were talking about on the wiki: http://algorithmicbotany.org/papers/#abop


SpaceAce(Posted 2014) [#5]
I think their main usefulness is in modeling natural systems. I am sure they could also be used in pretty cool ways as terrain/background generators.

I can't seem to let go of this little project. I added some new functionality.

My LSystem code can now render each individual segment of the curve as it is calculated, rather than only updating once per iteration.




Even cooler, the curves can now be drawn with ellipses instead of line segments.




You can adjust the x- and y-radius of the dots, for some pretty neat effects.




Why0Why(Posted 2014) [#6]
This is really cool. Are you interested in sharing the code?


SpaceAce(Posted 2014) [#7]
SpaceAce's L-System, uh, system: now with variable-speed rendering, picture-in-picture, and alignment.



Even though I said I was reluctant to do so since there didn't seem to be much interest, I ended up cleaning up the code. Then, I spent two days adding new features, and now it's a little bit of a mess, again. I think it's fit to share, as long as no one expects it to be an example of brilliant (or even intelligent) coding. That said, it's over 1,000 lines across nine or ten files. I don't know about pasting it into code tags. I could do that, but Pastebin might be a better option, or even a project on Google Code or a similar service. Let me know how you guy(s) want it.


itto(Posted 2014) [#8]
I'd be much interested in fiddling with the code, but please create an open source repository at GitHub or Bitbucket :)


SpaceAce(Posted 2015) [#9]

I'd be much interested in fiddling with the code, but please create an open source repository at GitHub or Bitbucket :)



I forgot all about this. The code is awful, but you're welcome to it. I posted a thread, here: http://www.monkey-x.com/Community/posts.php?topic=10075

Here are a couple new things made with my program: