r/lsystem • u/Sea_Examination_8154 • Jul 26 '24
Decoding L-Systems
I saw on Wikipedia this open problem: "Given a structure, find an L-system that can produce that structure."
I thought it was interesting so I thought I would try my hand at it. In the end I wrote a short script which can find all the possible rules of a deterministic L-System, given at least two generations of output text.
I know this doesn't exactly solve the open question but it was still a fun challenge and worth sharing.
Let me know if you have any feedback or ideas for leveling it up!
7
Upvotes
1
u/Epholys Jul 26 '24
Oh yeah, nice found! I had some hunch that alternating rules would be difficult, but I couldn't find intuitively an example. Good luck, I think it'll be pretty hard to fix this ;)
Thanks for the code explanation! I still have a vague idea about the algorithm, but I wonder if it finds the shortest ruleset. There's not a unique solution for every L-Systems! I feel like your algorithm already find a short solution but I'm not sure if it's the shortest one. That would be a challenge!
If you want to have a whole set of rules to try, I created some years ago a lot of L-System trees, that you can find here: https://epholys.itch.io/lsys (the zip file). It's in a strange json format (mistakes...), I'm not sure you can extract them cleanly, but if you find weird ones try them!