Coding, JavaScript, live stream, Living Code, Milestones, Simon teaching

Live Stream #6. (Mostly) Chapter 2 of Living Code: Forces.

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.

All as part of his “Living Code” Course. The lessons in the course are loosely based on Daniel Shiffman’s book “The Nature of Code“, but focus on JavaScript.

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:

Schermafbeelding 2018-01-11 om 20.38.49Schermafbeelding 2018-01-11 om 20.39.27Schermafbeelding 2018-01-11 om 20.39.42Schermafbeelding 2018-01-11 om 20.40.01Schermafbeelding 2018-01-11 om 20.40.20Schermafbeelding 2018-01-11 om 20.40.45Schermafbeelding 2018-01-11 om 20.41.01Schermafbeelding 2018-01-11 om 20.41.14Schermafbeelding 2018-01-11 om 20.41.24

Coding, JavaScript, live stream, Living Code, Milestones, Murderous Maths, Simon teaching

Live Stream #4 on December 14. Living Code > Vectors.

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:

Coding, Exercise, Geometry Joys, Java, motor skills, Physics, Simon makes gamez, Together with sis

The Snowball Throwing Game in Processing

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.


This slideshow requires JavaScript.

Coding, JavaScript, Milestones, Murderous Maths, Simon's Own Code

More Vector Functions. The Damned Matrix Class.

Simon made another attempt to conquer vector functions, now in JavaScript (in Atom) and got stuck once he reached the Matrix Class, again. He had already tried this in Java, Python and C#. He did successfully complete the 2D, the 3D and the 4D classes.

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:




Codea, Coding, Java, Milestones, Murderous Maths, Notes on everyday life, Physics, Python, Simon's Own Code

Back to Python (and C#)!

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 – 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:

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:

Coding, Geometry Joys, JavaScript, Murderous Maths

Steering Behaviors: flow field, dot product, scalar projection

Simon’s big project the last couple of days was about making a steering behaviors database, complete with a navigation menu (in Cloud9):

Steering Behaviors Navigation Menu 24 Mei 2017

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:

Craig W. Reynolds Steering Behaviors Seek and Flee 25 Mei 2017




Simon also made a “Seek” example in the language called Lua (from the Codea app):


The second example was about Pursuit and Evasion:

Craig W. Reynolds Steering Behaviors Pursuit and Evasion 25 Mei 2017



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:

s=|{\mathbf  {a}}|\cos \theta ={\mathbf  {a}}\cdot {\mathbf  {{\hat  b}}},

or the way Simon put it:


Coding, Geometry Joys, Java, Milestones, Murderous Maths, Physics

Pendulum Force

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:

Biology, Coding, Java, Murderous Maths

Autonomous Agents and Genetic Algorithms

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”.

Shakespear Evolution 18 Apr 2017