Exceptional plant progress

September 05, 2017

Latest video, plant timelapse:

SO MUCH PROGRESS since the last update!!

Implementation Notes

A few weeks ago, I had been struggling with exactly what data structure to use for the plant. It felt like the NxN grid was the wrong data structure – code was hard to write, the abstraction just didn’t feel quite right, etc. I wanted something that could more properly represent each “node” of plant, and I wanted something that contained pointers to the next node(s) of the plant, and a pointer to the parent node…

And then I realized…

Clearly the right data structure was a TREE!

Once I got the plant represented as a 7-ary tree (and once I finally got all the bugs out…), the rest of the code was pretty straightforward, though it’s not too pretty.

Things I could (but probably won’t) clean up later:

A fun intermediate stage

When I was playing around with plant growth algorithms, I made this happen:

Didn’t stick with this algorithm, but it’s fun to watch!

Console debugging

I was having trouble getting my 7-ary tree working perfectly, and honestly what I should have done was written a unit test for the PlantNode data structure itself. Had I gone that direction from the beginning, I am certain it would have saved me time. But that’s not what I did!

Instead, I mostly suffered through print-statement debugging, until I realized that the tree growth would be easier to “see” with a little bit of color.

So I wrote a debug mode that was kind of cool, where I color-coded each branch of the tree, and matched the console log statements to the color of the branch:

TODOs for next time


Comments