Lito Nicolai

Summarized using AI

Botany with Bytes

Lito Nicolai • October 10, 2015 • Burbank, CA

In the talk 'Botany with Bytes' by Lito Nicolai at the LA RubyConf 2015, the intersection of botany and computer science is explored, emphasizing how plants can be likened to small computing systems. The presentation utilizes the Ruby 'graphics' gem to create visual models of various plants, illustrating how they grow and interact with their environment through computational principles.

Key points discussed include:
- Introduction to the Ruby 'graphics' gem and its capabilities for drawing and modeling.
- Explanation of L-systems, a concept developed by botany-inspired mathematician Aristid Lindenmayer, to simulate the growth patterns of plants through simple rewriting rules.
- Discussion on various grammar systems in computer science, such as regular expressions, context-free grammars, and recursively enumerable grammars and their relationship with L-systems.
- The demonstration of a basic implementation of an L-system to represent the growth of algae using a string manipulation approach, alongside the use of turtle graphics.
- A consideration of how these computational models can visualize complex structures, such as branches and leaves, that resemble natural plant formations.
- Insights into Alan Turing's contributions to understanding plant growth, particularly his notion of phyllotaxis, and how it can be simulated through L-systems, maintaining specific angles of growth.
- The fractal-like nature of plant structures that emerge from simple iterative rules, exemplified by the growth patterns of plants like Euphorbia and Oregon Grape.
- Conclusions drawn regarding the complexity of life and plant growth, highlighting that even simple mechanisms can lead to intricate patterns that are observed in natural flora.

Overall, the presentation serves to illustrate how computational thinking can provide valuable insights into biological processes, enhancing our understanding of plant behavior while also drawing parallels to fundamental computer science concepts.

Botany with Bytes
Lito Nicolai • October 10, 2015 • Burbank, CA

Botany with Bytes

Plants are tiny computers. As they grow, the sprouts are computing from first principles how to be a plant. We’ll see how they do it! This talk uses Ruby and the ‘graphics’ gem to build models of all kinds of plants, from algae blooms to juniper branches. We’ll touch on rewriting systems, formal grammars, and Alan Turing’s contributions to botany. We’ll look at the shapes of euphorbia, artichoke, and oregon grape, and how these come from plants’ love of sunlight and greedy desire for growth. By the end, we'll have a series of great visual metaphors for fundamental computer science concepts!

Help us caption & translate this video!

http://amara.org/v/HTA1/

LA RubyConf 2015

00:00:23.210 So, my name is Lito, and this is Botany with Bytes. This talk has a lot of images, and to do that, it uses a Ruby gem called 'graphics', written by Ryan Davis, who is sitting in the back over there.
00:00:28.350 It has axes in all the right directions and it is absolutely my favorite graphics library. I've used it, and although it's still in beta, you can install it with 'gem install --pre' and see a whole bunch of examples. It's very easy to use.
00:00:34.470 All of my code is on GitHub at GitHub/lito_nicolai. You can also see my Twitter handle down there at the bottom of my slide, so feel free to tweet at me; I appreciate it! Now, imagine you are algae. We'll call you 'Alpha', and you're going to do what algae do, which is make more algae in a process called mitosis.
00:00:58.860 When you're done, you'll still be there, but you'll also have created a baby algae. This process continues: your baby will grow up, then you'll split off more algae babies. This keeps going and going. To represent it with letters, we might say 'A, B, A, B'. Incidentally, for the same reason as breeding rabbits, this will give you the length of each generation in a Fibonacci sequence, so like 1, 2, 3, 5, 8. This concept was first described by a botanist named Aristid Lindenmayer. It's important to note that he was actually human and not a plant.
00:01:44.310 He called these systems, after himself, 'L-systems'. They're very simple and consist of a starting point (an alga) and some rules, like 'one splits' and 'the baby grows up'. Let's talk about computers for a moment. You may recognize this system as a rewriting system. We know those from the game of life, if you've ever done that; it rewrites a grid based on some rules.
00:02:26.550 The famous fractal, the Koch snowflake, rewrites a line. This one rewrites a string. Since it's strings and since it's rewriting, this is a grammar. Now, what is a grammar? The simplest and easiest definition of a grammar is a set of rules that defines what strings, grids, or lines can be created.
00:02:59.220 The rules can be in the form of producing by replacing cells in the game of life, like the production rules of an L-system. For the purpose of this talk, I'm going to flip it around a little. Instead of asking, 'What strings can you make?' I'll provide something more familiar, asking 'What strings can you match with these rules?' Our favorite example of this as programmers is regular expressions. For instance, here's a regular expression, which raises the question: What strings does it match?
00:03:39.420 When we talk about grammars, we can categorize them in terms of their capabilities. Regular expressions require a special type of computer called a finite automaton. The computer I’m talking about here is far more powerful than that; we don't even need to worry about it in this context. We can find a little square to describe all of the strings any regular expression can generate.
00:04:09.850 If you're like me and have naively tried to parse HTML with a regular expression, you know that it simply doesn't work. So there must be more to the story. There is a subcategory of grammars called finite grammars that we will just ignore for now. Beyond regular expressions, we also have context-free grammars. These are strings that can't be matched with just a finite automaton; they require a stack or some kind of memory structure.
00:04:46.360 More advanced than that, we have context-sensitive grammars and examples include languages like C++. These need some kind of random access memory to keep track of what's happening, such as determining if a term is a function call or an instantiation of a class in C++. Beyond that, we also have grammars called recursively enumerable grammars that may require an infinite amount of memory.
00:05:13.240 I'm not sure where Ruby fits in; it's somewhere between context-sensitive and recursively enumerable. Every time I open up 'parts.y', I try to decipher it but usually end up closing it after a few lines. And, of course, Perl is not possible; that’s not a joke—it’s genuinely very complicated. My talk is about L-systems and their classification within these various models.
00:05:55.900 L-systems match some finite grammars, some regular grammars, some context-free grammars, and some context-sensitive grammars. Now, there are other L-systems called IL-systems that we're not going to discuss because they are even stranger. L-systems provide a unique perspective on grammar systems, and I want to give you a concrete example to make these ideas more accessible.
00:06:57.050 Consider matching nested balanced parentheses. An L-system can represent an arbitrary number of parentheses all stacked up and perfectly nested. However, it can't match just balanced parentheses. A context-free grammar does that; yet, a regular expression cannot match either. Let me show you a quick implementation of an L-system. Notice that it's quite simple: we will focus only on the core logic; the rest is just bookkeeping of rules and the initial state.
00:08:06.170 Here’s how it works: you have a string, which we’ll call the state. You split it up, apply the rules using a dot map, and then join it back together. So imagine an alga and a baby alga—split, apply rules, and join. You can throw this into a loop and it works perfectly, creating a line of algae. However, what I'm looking for is more dimensions, so let’s discuss sprouts, a miniature tree starting with a leaf where each leaf branches off into a left and right leaf while each stem lengthens.
00:09:19.350 Now, we haven't yet talked about how to draw things in two dimensions. I'm going to introduce a very simple method called turtle graphics. Have you ever encountered it? It's a programming language called Logo, which some of you may have learned in grade school by programming little spirograph drawings. If you’re not familiar, the mechanism involves controlling a turtle, moving it forward, and rotating it. You can save its position and direction onto a stack, turn left and right by arbitrary angles, and recall previous states to draw various diagrams.
00:10:07.020 We will use the turtle to evaluate strings of symbols. For example, here’s a string we’ll have it draw: ‘S’ for forward and left bracket ‘[’ for turning left, while right bracket ‘]’ means turning right and pushing or popping the stack. Now, let me illustrate how that works. The turtle knows that ‘S’ means to move forward, so when it encounters the left bracket, it turns left and moves forward again.
00:10:20.850 This mechanism of drawing demonstrates how the turtle interprets these commands. I choose this drawing technique because it’s an easy way to explain how it operates. Now, let's go back to the sprout and define for the turtle how to draw a leaf on the end of a stem. When it reaches the end of a stem, it will save its current state, turn left, draw a leaf, restore the previous state, turn right, and draw another leaf. This will be enough for us to draw in two dimensions.
00:11:16.660 So, using the concepts we’ve discussed, we will tell the turtle what each of the symbols represents. In the first generation, we simply see a leaf, which is quite uneventful. The second generation is just as bland, so we won’t spend time on it. However, the following generation becomes interesting, and I'm going to walk you through it to illustrate how the turtle interprets the drawing instructions.
00:11:43.760 Picture the stem: it saves the current position, turns left to draw another stem, saves its position again, draws another leaf, and so on. You get the picture, right? It's important to realize that trees don’t actually look like this. There’s a plant known as the Droseras webanata that resembles this structure, but it’s a rendering since there are no public domain images of it available online.
00:12:46.080 To provide a better match to reality, let's examine a juniper branch. It's challenging to decipher from the grammar alone what it looks like, but if we start with a twig and execute certain transformations, we can evaluate it to approximate this shape. It won't be a perfect match to a juniper branch, but it's closer to the growth patterns that trees naturally exhibit.
00:14:12.720 Earlier, we talked about how plants 'compute' as they grow. This computation is not just theoretical; there are actual mechanisms behind it that have been studied. One fascinating piece of work in this field is by Alan Turing, who described the processes within plant growth as interactions of charged particles. His hypothesis of general phyllotaxis discusses how each leaf seeks to equilibrate with its neighbors while simultaneously searching for growth hormone.
00:15:10.300 Thus, when simulating this phenomenon, it would be challenging to track all the fluids involved effectively, leading us to a simpler model. We can see how much this understanding has evolved over time, and Turing's contributions have greatly enhanced our knowledge of plant biology while intertwining it with computational theory.
00:15:55.880 In fact, Turing even visually represented this in his notebooks, where he noted that each leaf emerges at a particular angle from the previous one, a consistent angle—about 137.5 degrees—that creates the spiraling nature of growth. Now equipped with this concept, we can use L-systems to simulate this structure in growing plants, telling the turtle to grow at this angle at each step.
00:16:37.800 Returning to our algae in three dimensions, we can envision this growth process continuing infinitely. We should also consider that life is complicated, leading to branching structures that create intricate formations, making it hard to draw more complex representations. To facilitate understanding, I will simplify the model so we can see how the cells grow and contact each other.
00:17:14.400 By focusing on the centers of these cells and working with their connections, we can visualize a crystalline structure. Each cell can maintain a set distance from its neighbors as they grow. The result is a lovely pattern that can be seen in various plants, such as Euphorbia, which I frequently observe in the Pacific Northwest, along with Oregon Grape and other similar flora.
00:18:36.550 Let’s take a moment to discuss surface growth. Plants grow on flat surfaces that don’t curve. For example, if you have a sphere, it represents positive curvature, while the shape I am presenting is negative curvature, resembling a saddle shape. While mathematicians have defined these properties in theory, plants grow naturally through cell division, and it’s fascinating to see this phenomenon in action. You can verify it personally—approach an Oregon grape and marvel at its leaves without expecting it to explain its growth mechanism.
00:19:46.750 Thank you very much for your attention!
00:20:01.520 I am currently looking for job opportunities in Seattle, Washington, or remote positions, if you're particularly interested in hiring.
00:20:15.330 Does anyone have questions? The first question is about the gem; it's a method for drawing on the screen and not my creation—it's authored by Ryan. You might hear more about it in his talk later. It’s similar to Processing, all in Ruby, being an interface to SDL (Simple Direct Layer) for on-screen drawing. You can plot points, draw lines, create circles, and use Ruby’s matrix library to perform 3D math if that interests you. It is designed for simulation code rather than game programming. So I recommend giving Ryan's library a try.
Explore all talks recorded at LA RubyConf 2015
+1