Simon hadn’t been writing in Python for months but seems to be quite fluent still, here using the Python space in Processing for the first time:
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:
Simon has created animations visualizing sound waves (Triangle, Sawtooth, Square and Sine waves) in Processing (Java), using wave functions.
These are the functions he used for the Sawtooth, Square and Sine waves:
Not to confuse “sine” with “sgn” (sgn standing for sign):
He was inspired by the logarithmic and power functions that he was studying during his math class yesterday. Simon was trying to draw both types of functions in Grapher on his laptop, but only succeeded for the power functions (because there were no subscript option for the logarithms).
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).
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.
Simon has created a great new game in Processing: The Hero Game! It is somewhat like the good old Mario, except that Simon has no idea what Mario is and came up with the concept himself. The game is based upon Circle-Rectangle Intersection, something that he was studying for the past several days. It was impressive to see how quickly he wrote the program for the game, I think it took him something like an hour, while waiting for dinner. The game has a hero (Simon), represented by the yellow circle, obstacles (from below and above) and money that the hero collects to get points. The game stops once the hero hits an obstacle. Simon is planning to add extra random obstacles and maybe also create a winning score threshold (around 50 or 65, he says). His own highest score so far has been 35.
Below are the making-of videos, step by step:
Update: Simon added trees!
Simon created his very first video game completely on his own. Everything in this game he came up with by himself – from the original idea and design to the final code. The game is about a little man (actually, Simon himself) jumping over the waves in the sea. Every time he lands on an actual wave it’s game over.
Simon used collision detection (point-rectangle instead of rectangle-circle collision detection) and array lists to duplicate the waves. He created an illusion of 3D by choosing the viewing angle “almost as if it were an orthographic camera”, he explains.
The code for this game (in Processing i.e. Java) is available on GitHub at
The making of, step by step:
Simon had trouble with the game over function. Originally, it was only triggered once the player clicked the mouse to jump again while on a wave, instead of reading to the circle-rectangle (little man-wave) collision. Simon asked about this problem in the Coding Train slack channel and got some great responses. Eventually he solved the problem is his own way (see the “Debugged” video):
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:
Note: See the update at the bottom of this post!
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):
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 2. STEERING equals DESIRED minus VELOCITY:
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: