Tetris in Processing continued

Inspired by a Meth Meth Method Tetris video, Simon has come back to his Tetris project in Processing, something he started a long while ago and never finished. At the moment, the primary difficulty he experiences is having the pieces accumulate at the bottom of the grid and not vanish immediately once hit by other pieces. Work in progress.

Advertisements

Simon a Processing member!

Simon has become a Processing Foundation member! We love Processing! Anyone is welcome to join, just go to Processing.org to support this wonderful open source platform – what better way to celebrate this season than donate for a more enlighten future? We can rightfully say that Processing has played a huge role in Simon’s development as a young programmer so far and he definitely hopes to become an even more active member in the years to come.

Schermafbeelding 2017-12-21 om 17.52.24

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.

Simon explains K Means Clustering

Simon has prepared this implementation of “K-Means Clustering” in Processing as a gift for Daniel Shiffman, who is plainning to talk about this Machine Learning model in one of his upcoming live sessions on the Coding Train channel.

Simon writes: K-Means Clustering is a type of Machine Learning Model. It’s for “Unsupervised Learning” (meaning you have data with no labels).

Link to Simon’s code on GitHub: https://github.com/simon-tiger/k-means-clustering

Link to pseudocode by Siraj Raval: https://www.youtube.com/watch?v=9991JlKnFmk&spfreload=1

 

 

The Genetic Algorithm Game Bug Solved!

Simon’s version of the Citius Invaders game in Processing is finally working! The big bug that seemed so unsolvable (enemies endlessly crossing over) has been defeated!

Siraj Raval presented this game in Python during Week 9 of his “Math of Intelligence” course. Simon’s is a simplified version that still incorporates a genetic algorithm.

Link to code on github at: https://github.com/simon-tiger/citius-invaders/

Link to our previous post on this project: https://antwerpenhomeschooling.wordpress.com/2017/11/23/problem-with-a-genetic-algorithm-game/

Link to Simon’s archived Live Stream about the project: https://antwerpenhomeschooling.wordpress.com/2017/12/01/live-stream-30-november-speechjs-and-citius-invaders/

Problem with a Genetic Algorithm Game

Simon has been working very hard at making his version of the Citius Invaders game that Siraj Raval presented in Python during Week 9 of his “Math of Intelligence” course. It’s a simplified version that still incorporates a genetic algorithm. Simon’s plan is to code the same game in P5 during his next live tutorial (at 17:00 CET on 30 November). Unfortunately, after many lines of code in several files, when the game was nearly ready, he faced a problem he doesn’t know how to resolve. He tried getting some online help via the Coding Train Slack channel but didn’t get much feedback. The code is now on github at: https://github.com/simon-tiger/citius-invaders/

Here is how Simon describes the problem:

Hi! I’m working on a “Citius Invaders” game, and I have a problem.
In the game, there are enemies, a spaceship, and bullets that it shoots.
The parameters of the game are:
* The game starts with 6 enemies.
* The minimal amount of enemies is 4.
* The maximal amount of enemies is 100.
The rules of the game are:
* When a bullet collides with an enemy, the bullet and the enemy get deleted.
* If there are 4 enemies on the screen, you’re not allowed to shoot any bullets any more.
* If there are 100 enemies on the screen, you’ve lost the game.
* The enemies reproduce every 5 seconds (this amount of time decreases every generation).
The goal of the game is to stay as close to 4 enemies as possible.
The problem is that: After the 5 seconds, the enemies don’t stop crossing over! I think the order that I’m crossing them over is wrong. They breed (cross over) forever and that makes the game pause forever. Maybe the algorithm in which I let them cross over is wrong. I have a `while` loop somewhere, maybe it became a forever loop. The `while` loop is at line 52 in `Population.pde`:

 while (!selectedEnemies1.isEmpty() || !selectedEnemies2.isEmpty()) {
 int index1 = int(random(selectedEnemies1.size()));
 int index2 = int(random(selectedEnemies2.size()));
 if (index1 == index2) {
 index2 = (index2 + 1) % selectedEnemies2.size();
 }

Below are a some videos showing Simon at different stages of the project. In the top video, he speaks of the difficulties he encountered with the frame rate and the genetic algorithm.

 

 

Simon building a Perceptron in Processing

Simon has already built a Perceptron before, several months ago, while following along with Daniel Sgiffman’s Coding Train channel. This time around, he is writing his own code ad doing all the matrix calculations himself. He hasn’t finished programming this network yet, but it’s a good start:

 

DSC_2874

Doing Matrices in Khan Academy’s Precalculus course:

Schermafbeelding 2017-11-16 om 12.34.36

28 times 28

Simon programmed a presentation to explain why 28×28 is not the same as 20×20 + 8×8 geometrically. The code is quite complicated and involves some trigonometry and conditional statements: the grid is divided into different parts every time Simon clicks and depending on how many times he has already clicked. This is typical Simon – coming up with an inherently arduous and complex system to visualise the beauty of the world around him, even of the seemingly trivial things. By the way, the inspiration for the 28×28 grid came from Simon’s favourite math channel, 3Blue1Brown and its latest video on Neural Networks (the grid was used to explain computer vision).

Simon is doing quite a lot of sums in his head nowadays, looks like it’s a new trend. Today, while bathing in the fountain outside, he was calculating how long 1/16th of a minute lasted. And a couple days ago, while waiting for his appointment at the hospital, he calculated how long it would take someone to read a whole page of random numbers, taking an educated guess that one takes 4 seconds to read out one number and remembering Daniel Shiffman mentioned there were 100×5 numbers per page in his book.

Cannon Game in Processing

Simon shows the Cannon game he created in Processing (Java). He says he was inspired by the Stackoverflow forum, where he saw an example of the game and later wrote the code for a similar game himself. I saw him quickly write the code in a matter of perhaps two hours. Simon will post his code on GitHub once he has added a couple extra features.