This is Simon’s translation online in Cloud9: https://ide.c9.io/simontiger/smart-rockets#openfile-README.md
This is when he first discovered the bug and tried different solutions:
And this is the same project before he introduced the genetic algorithm:
In the next video Simon boasts he found two errors in his code and hopes that the problem would be solved, but alas, the rockets still vanish from the canvas after a few seconds:
Simon is officially stuck here.
On the positive side, this project did get us to read more about the actual human DNA and the way it works.
Yesterday Simon spent the whole day studying the concept of Cellular Automaton (CA), a discrete model of a system of “cell” objects used in physics, math and theoretical biology. He learned a lot from Daniel Shiffman’s tutorials on Cellular Automata and his book The Nature of Code (Chapter 7).
Simon describes Cellular Automaton as a set of rules for getting nature-like patterns. 1D cellular automata are static (think of a pattern resembling the Pascal triangle) and 2D are not static (the most famous example is Conway’s Game of Life).
The mathematician who made cellular automata a big thing (and even Turing-compatible!) was Stephen Wolfram. Simon also looked at some of Wolfram’s writings. Wolfram’s book A New Kind of Science is intimidating (in content and size) but full of graphic illustrations and available for free at http://www.wolframscience.com/nksonline/toc.html
A CA is basically a grid where cells live, each cell in a particular state (the simplest example being “1” or “0”). In Processing, it’s possible to have a CA draw a beautiful pattern this way. Simon tried to write a CA program in another language. He tried writing it in Python on his RaspberryPi first, but I overheard him say “don’t know how classes really work in Python, let’s try Ruby – I know how classes work in Ruby!” Then I saw him move over to the desktop and plug his long forgotten Arduino in. He said he now wanted to translate a CA code into C. Of course, there would be no pattern, but he wanted to have the Arduino “spit out numbers in the console” instead. Eventually he got an error and gave up, but it was intriguing to observe him.
The videos below show Simon talk about CA and program a CA in Arduino (C):
In these videos Simon explains looping through an array and adding while simultaneously removing things from that array. He recorded this presentation while working on an evolution simulation (Evolutionary Steering Behaviors, see previous post).
This challenge is part of the spring 2017 “Intelligence and Learning” course at NYU’s Tisch School of the Arts Interactive Telecommunications Program. Simon was especially happy to find out that Daniel Shiffman left a couple of personal comments praising Simon’s progress and offering help in pushing his code to Danniel’s GitHub repo.
Here is Simon’s translation on GitHub: https://github.com/simon-tiger/steering-behaviors-evolution
The rockets have their own DNA consisting of four genes:
The challenge step by step:
Today Simon spent hours watching videos and reading Daniel Shiffman’s book The Nature of Code, concentrating on more complicated matters than ever: autonomous agents and evolution (genetic algorithms). In The Nature of Code there are two separate chapters covering these topics. The term autonomous agent is defined as “an entity that makes its own choices about how to act in its environment without any influence from a leader or global plan”. This basically means that Simon has decided to try programming smart entities, that are like living things (have their DNA’s, behaviours, evolution).
The Autonomous Agent chapter also talks about steering force:
In the videos below, Simon has studied the steering behaviors in Daniel Shiffman’s code (Seek, Flee and Arrival) and changed the code slightly (third video) to be able to switch between the behaviours with a click of the mouse:
I also saw Simon go through the paper called Steering behaviours For Autonomous Characters by Craig W. Reynolds and reading about Persuit and Evade steering behaviours at this game development page.
In the video below Simon adjusted the Evolve Flow Field code to be able to see the possible behaviours (velocity vectors) of his smart rockets.
The code comes from the chapter Evolution of Code in Daniel Shiffman’s book, the chapter mainly devoted to genetic algorithms: it looks at the core principles behind Darwinian evolutionary theory and develops a set of algorithms inspired by these principles.
One of the most interesting notions Simon came across today was fitness, as in survival of the fittest. In the video you see Simon creating obstacles for the smart rockets. Together we observed how, as many generations of rockets passed, they learned to go around the obstacles better. This was possible because the rocket’s fitness was programmed to be greatly reduced every time it hit an obstacle.
All the rockets also have DNA’s: “We are marching through the array of PVectors and applying them one at a time as a force to the rocket”, Daniel Shiffman explains.
Simon also learned about genotypes and phenotypes, mating pool, crossover and mutation. He loved Daniel Shiffman’s example about haw many generations of strings with 18 random “genes” it would take to write “To be or not to be”.
What sort of literature do you fancy in the evening? Simon’s downloaded the book The Algorithmic Beauty of Plants tonight.
Here Simon explained to me how L-systems and Cantor Set worked:
An L-system or Lindenmayer system is a parallel rewriting system and a type of formal grammar. An L-system consists of an alphabet of symbols that can be used to make strings, a collection of production rules that expand each symbol into some larger string of symbols, an initial “axiom” string from which to begin construction, and a mechanism for translating the generated strings into geometric structures.
Simon says that an L-sestem is “also a context-free grammar that can have infinite generations”.
The Cantor set is a set of points lying on a single line segment that has a number of remarkable and deep properties.
Simon followed the book and Daniel Shiffman’s tutorial on L-Systems to create beautiful trees and other recursive patterns in
And “what you also might need by an L-system is a String Buffer”:
Simon did another coding challenge by Daniel Shiffman today, this time a short one called Phyllotaxis. You might be thinking, what in heaven’s name is Phyllotaxis? As it turned out, it’s the place where botany meets math! Phyllotaxis basically describes the arrangement of leaves in a plant, a repeating spiral that can be represented by a fraction describing the angle of windings leaf per leaf.
The numerator and denominator normally consist of a Fibonacci number and its second successor. The most famous example is the sunflower head. This phyllotactic pattern creates an optical effect of criss-crossing spirals. In the botanical literature, these designs are described by the number of counter-clockwise spirals and the number of clockwise spirals. These also turn out to be Fibonacci numbers. In some cases, the numbers appear to be multiples of Fibonacci numbers because the spirals consist of whorls. Phyllotactic patters are also closely related to the golden section in geometry.
The challenge Simon tried out today involved building an animation of a growing phyllotactic pattern.
After we shot the second video Simon corrected himself – he meant converting from Cartesian to Polar and not vice versa as he had said in the video. But what is Cartesian and Polar? And how exactly do you convert between them? We found a graphic explanation on Mathsisfun.com :
In this video Simon shares his idea on the use of the EMG SpikerBox module (from the LittleBits Bit Lab) that detects the electrical activity of human muscles non-invasively using simple skin surface electrodes. EMGs can be recorded from large muscles, or individual motor action potentials ( “spikes”) from smaller ones. Simon suggests using the EMG module as an exercising aid.
We have also watched the EMG video tutorial to learn more about how human muscles work and looked triceps and biceps up in the encyclopedia. Simon was excited to hear that our movements are also guided by electric impulses!
Simon’s eternal love for invertebrates made sure he actually enjoyed spending a short while at the Antwerpen Zoo this afternoon. He was glued to the aquariums with sea anemones and corals, going on and on about the overwhelming percentages of invertebrates among the animals, the echinoderms and the crustaceans. What surprised me was that he knew the way to the Aquarium after studying the map for just a couple of minutes. We’ve got a year-long pass to the zoo now, will try to keep it short every time as he gets exhausted easily and wants to get back home to his studying.