Flocking System Painting with Pixels

Flocking painting Live Video 8 Aug 2017

This is one Simon’s most beautiful projects recently! Simon saw the idea to link the webcam image to the boids of a flocking system in a video by Daniel Shiffman, but the code featured in this project Simon wrote himself. The Flocking code is based on Daniel Shiffman’s example from his book The Nature of Code. (Flocking is a steering behavior that consists of separation, alignment and cohesion – which are also steering behaviors – combined).

Simon’s sis also posed for the camera:

Flocking painting Live Video 8 Aug 2017 2

Simon is also about to make a JavaScript version of this fun project, because JavaScript allows to host it easily online, so that everyone can play with it. With JavaScript, he may even be able to write it in an online editor, so there won’t even be a need to host it. Check in later for an update to this post!

UPDATE: Simon encountered a problem trying to translate his Flocking System Painting with Pixels into JavaScript: P5 runs much slower than Processing after Simon added steering behavior. He doesn’t know how to solve this. Simon’s JavaScript code is online at https://codepen.io/simontiger/pen/ZJKBbN?editors=0011

Circle Intersection with Perlin Noise in Processing (Interactive)

Simon built a beautiful interactive circle intersection program in Processing, in which the circles detect intersection and change colors (according to Perlin Noise) once it occurs. The player can control the number of circles by adding and removing them in two modes (mouth clicked and mouth dragged). Simon added a button to switch between the two modes. (Loosely based upon Daniel Shiffman’s tutorials on checking object intersection).

 

 

Maze Generator Game in Processing

Simon has turned Daniel Shiffman’s Maze Generator Coding Challenge (generating a maze using the Depth-First Search Recursive algorithm) into a game in Processing (Java). It’s not fully operative yet, as the player can partially walk through walls, but Simon did get quite far and even received positive comments from Daniel Shiffman.

Simon’s own little neural network

Connected Perceptrons in Processing 26 Jul 2017

This is one of Simon’s most enchanting and challenging projects so far: working on his own little AIs. As I’ve mentioned before, when it comes to discussing AI, Simon is both mesmerized and frightened.  He watches Daniel Shiffman’s neural networks tutorials twenty times in a row and practices his understanding of the mathematical concepts   underlying the code (linear regression and gradient descent) for hours. Last week, Simon built a perceptron of his own. It was based on Daniel Shiffman’s code, but Simon added his own colors and physics, and played around with the numbers and the bias. You can see Simon working on this project step by step in the six videos below.

His original plan was to build two neural networks that would be connected to each other and communicate, he has only built one perceptron so far.

 

 

 

 

 

 

Fractal Trees Customized

This weekend Simon came back to his old fascination, Fractal Trees. This time he didn’t just follow along Daniel Shiffman’s coding challenges, but created customized versions of Daniel’s trees, adding color and physics in some cases or writing the code in object oriented manner:

 

 

 

 

 

DSC_0818

DSC_0819

Evolutionary Steering Behaviors Game

Note: See the update at the bottom of this post!

We’ve had quite a dramatic situation here for the past couple of days, after Simon turned Daniel Shiffman’s Evolutionary Steering Behaviors Coding Challenge into a game in Processing (Java) and then also in JavaScript (with p5). After completing the game in JavaScript, Simon wanted to add a new feature – a checkbox he programmed using the p5.js library. The checkbox would give the player the option to play with or without the timer, adjust the timer and also had a “New game” button. In the end it turned out that the checkbox didn’t really work. Simon was very upset and it took me hours to talk him into putting the game online even though the checkbox didn’t function (he wanted everything to be perfect) and ask for advice. “I have got a problem with a p5 element: In my setup function, I defined my checkbox. In my reset function, my checkbox is undefined. Why?” – Simon asked in the “Share Work” section of the Coding Train Slack channel, where he has the opportunity to communicate with experienced programmers. He received quite a lot of help and was enthusiastic about it at first, but for some reason, he hasn’t tried the solutions he was suggested. Perhaps it’s his gut feeling that the bind function suggested is still too difficult at the moment. I have decided not to push anymore and trust him on this one, although it’s always a dilemma for me whether I should sometimes “force” him into taking instructions from others or let him solely rely on his fantastic intrinsic autodidact mechanisms. The second seems to work better in terms of the learning process, but I do push him into sharing his work.

Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 3Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 4Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 5Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 6Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 7Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 8

Evolutionary Steering Behaviors game. Asking help in Slack 10 Jul 2017 2

Simon’s game is online at: https://simon-tiger.github.io/Game_SteeringBehaviorsEvolution/SteeringBehaviours_EvolutionGame_p5/

In the videos below Simon shows how he made the game. It’s an ecosystem type of genetic algorithm (with no generations), where the organisms (autonomous steering agents) clone themselves. The autonomous steering agents evolve the behavior of eating food (green dots) and avoiding poison (red dots). Simon added two invaders into the game, one giving food and the other randomly spreading poison. The player can control the “good” invader by moving him and making new food. The goal of the game is to make the agents survive for as long as possible.

The Processing (Java) version:

The thinking behind the game (Simon explains everything at the whiteboard):

The JavaScript version (now online):

In the last video, Simon talks about his problem with the p5 element.

 

Evolutionary Steering Behaviors game seek algorithm part 1. DESIRED equals TARGET minus POSITION:

Evolutionary Steering Behaviors game seek algorithm part 1. DESIRED equals TARGET minus POSITION 4 Jul 2017

Evolutionary Steering Behaviors game seek algorithm part 2. STEERING equals DESIRED minus VELOCITY:

Evolutionary Steering Behaviors game seek algorithm part 2. STEERING equals DESIRED minus VELOCITY 10 Jul 2017

UPDATE: When Simon saw Daniel Shiffman’s comment on Slack this morning (Daniel saying Simon did a fantastic job and that he might even include Simon’s game in the next Live Stream), he sat down and applied the bind function as suggested by his older peers above – without any incentive on my behalf! And it worked! I think we’ve hit a true milestone again. Simon has this growing feeling that he’s got friends out there, his tribe, who understand and who are ready to help.

One day later: Simon had another chat with his friends on Slack and got a lot of help with the last remaining small bug in his game (the New Game button didn’t start a new game if the player had chosen to play with no timer but jumped to Game Over instead). In the video below, Simon shows how that problem got solved:

Diffusion Limited Aggregation Tests in p5

Simon was busy with Diffusion-Limited Aggregation, the code he learned from Daniel Shiffman’s Coding Challenge about the generative algorithm “Diffusion-Limited Aggregation.” The DLA visual pattern is generated from random walkers clustering around a seed (or set of seed) point(s). Simon has made it possible to switch between different DLA examples in his sketch. Test 1 is available online at  https://alpha.editor.p5js.org/simontiger/sketches/H1Lobj7EW

 

Diffusion Limited Aggregation Test 5 30 Jun 2017

Simon built a website featuring Box2D helper

Simon created a website to assist people using Box2D. The website features the jBox2D helper.

Link to Simon’s website: https://simon-tiger.github.io/box2d-helper/

GitHub Issue about the project: https://github.com/CodingTrain/Rainbow-Topics/issues/616

Simon ported the code for the examples from the JavaScript version of the book The Nature of Code by Daniel Shiffman. The Box2D helper also comes from The Nature of Code.

Solar System in Processing Coding Challenge

Simon returned to the Solar System in Processing Coding Challenge by Daniel Shiffman – something he tried before and got stuck. He has now successfully completed both the 2D and the 3D parts:

 

 

 

 

 

Simon’s changes to Daniel Shiffman’s Spherical Geometry Coding Challenge

Simon talks about his changes to Daniel Shiffman’s Spherical Geometry Coding Challenge: He has rewritten the code in an object oriented manner. Later he also turned the sphere into an ellipsoid using three radii.

Object oriented (Simon’s idea):

Adding colour (Daniel’s feature):

Turning the sphere into ellipsoid (Simon’s idea):

Simon would also like to try this with a cylinder:

DSC_0638

Simon wanted to share his code in a readme in GitHub but he didn’t manage to create one within the specific (Sphere Geometry) project. Here is a screenshot of him sharing the code in Slack chat (for Coding Train fans):

Spherical Geometry sharing in Slack 29 Jun 2017