Simon’s latest live stream on Thursday, January 11 was a blast! For the first time in his programming career he actually had quite a few viewers – largely thanks to Daniel Shiffman, who posted an announcement about Simon’s live session in his Twitter:
During the session, Simon recorded 6 tutorials:
- a bonus video about vectors,
- a video about forces in general,
- a video about mass,
- a video about the Friction Force,
- a video about Air Resistance
- and a video about Gravitational Attraction.
Simon was worried in the beginning, because he had forgotten to prepare for the stream and had no choice but do the theory (on physical forces) on the fly. It was wonderful to see how the competent viewers gave him a helping hand every now and then and generally encouraged him in the live chat. He even got a real Q&A session in the end, something he had always dreamed of:
Simon debuted with his own coding course last week! The course is called “Living Code” and Simon has already planned all its sessions for the year ahead. He is going to teach the course as part of his live streams (once in two weeks on Thursday evenings at 17 CET), although not every live stream will include Living Code sessions.
In the first Living Code session (that was live on December 14), Simon introduced the course and its Chapter 1: Vectors. He talked about mathematical operations with vectors, their magnitude, acceleration and normalisation.
There were no crashes or technical issues this time and Simon remained amazingly focused and organised during the stream, he had actually created a schedule for himself beforehand (without any incentive on my behalf):
Timestamps for this live session (new):
– 0:00:00 – 0:05:00: Announcements
– 0:05:00 – 0:15:00: Starting Question & Answer
– 0:15:00 – 0:20:00: Intro to Living Code
– 0:20:00 – 0:30:00: What is a Vector?
– 0:30:00 – 0:40:00: Vector math: subtract, multiply, divide
– 0:40:00 – 0:50:00: Vector math: magnitude, heading, normalize
– 0:50:00 – 1:00:00: Physics: acceleration, (maybe) jerk
– 1:00:00 – 1:10:00: Ending Question & Answer
Please subscribe to our YouTube channel and you won’t miss a video or a live session!
Below is the archived version of Simon’s first Living Code course lessons:
Simon invented this fun game in Processing after he and his little sister had some proper winter fun outdoors in the fresh December snow (quite rare for the local climate and thus immensely cherished by the little people). The game is about throwing snowballs in such a trajectory that they stick to one another, forming a super-snowball. After I finished filming this, the two snowball throwers had such a great time with the game that I dare say the giggling effect from of this 2D simulation overshadowed the real snowball fight that had originally inspired it. They did love playing in the real snow on the next day though, until it melted away.
Simon built a program in Codea visualizing the absolute value of a vector:
During his math lesson this morning, he chose to discuss Matrix math with his tutor, so hopefully that’s going to help. Below are Simon’s notes on Vector Math and Matrix Math prior to the math lesson, his self-study:
Simon was preoccupied with vector functions for most of the day on Saturday, compiling what, at first site, looked like a monstrously excessive code in Processing (he recycled some of it from the Processing forum, wrote some it himself and translated the rest from Codea). Originally, he was gong to use the code to expand the 3D vector animation he made into a roller-coaster project he saw on Codea and wanted to create in Processing, but got stuck with the colors. What happened next was fascinating. In the evening I all of a sudden saw Simon write in a new online editor Repl.it – he was translating the vector code into… Python! He hadn’t used Python for quite a while. I don’t know what triggered it, maybe Daniel Shiffman noting last night during the live stream session that “normal people use Python for machine learning”. Simon also said he had sone some reading about Python at Python for Beginners and Tree House!
He isn’t done with his project in Python yet, but here is the link to it online: https://repl.it/JAeQ/13
Here Simon explains what he is writing in Python:
Simon did the 2D, 3D and 4D classes but eventually got stuck with the matrix class in Python. He then opened his old Xamarin IDE and wrote the 2D, the 3D and the 4D classes in C#. In the video below he briefly shows his C# sketch and talks about Cross Product in general:
And this is a video he recorded about vector functions (in Processing, Java) the day before:
Here Simon explains how to calculate the magnitude of a 3D vector. This is something he partially figured out on his own and partially learned from Daniel Shiffman’s tutorial on Trigonometry and Polar Coordinates.
Simon’s big project the last couple of days was about making a steering behaviors database, complete with a navigation menu (in Cloud9):
He managed to finish the first two examples – “Seek and Flee” and “Pursuit and Evasion” – and worked on the Flow Field Following and Path Following.
As recommended by Daniel Shiffman, Simon largely relied on the paper called Steering Behaviors For Autonomous Characters (written by Craig W. Reynolds from Sony). As Simon told me, he tried to guess the code to make the static drawings in the paper come to life. For instance, for the “Seek and Flee” example, Simon animated this drawing:
Simon also made a “Seek” example in the language called Lua (from the Codea app):
The second example was about Pursuit and Evasion:
Simon also explained to me how Flow Field Following worked:
Another steering behavior he scrutinized was Path Following. For Path Following, he first had to learn what the “dot product” was. In math, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors) and returns a single number.
The way Simon learns is usually by studying (deconstructing) and memorizing the formulas (even if he doesn’t fully understand them in the beginning). After he comes back to the formula later on he seems to have grasped the meaning of it. I often observe him actually apply different formulas in real life. When it comes to the “dot product”, Simon is in the beginning of the learning curve:
The formula for scalar projection is:
or the way Simon put it:
This is a beautiful “lecture” that Simon in his pajamas, chocolate paste adorning is face, game me Friday morning. He spoke about pendulum force, a force he was about to apply in a coding project.
The other videos form the very beginning of the lecture, with Simon plays with sine and cosine and explains why location, velocity and acceleration can be vectors and can be angles:
And this is the code where pendulum force is used. It’s an example from The Nature of Code book by Daniel Shiffman, from Chapter 3 on Oscillation:
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”.