Simon says he has attempted a Higgs Field model in Processing, but got more of a Brownian Motion simulation in the end. His code on GitHub: https://github.com/simon-tiger/Brownian-Motion

# Category Archives: Java

# Simon taking part in an art exhibition

Simon explaining his creative coding poster to artists from the Antwerp Art Academy at a small exhibition he was part of last Wednesday.

# Simon has created an “immortal” organism?

Simon opened up a genetic algorithm game he built about two years ago and made a fascinating discovery: one of the organisms seems to have become immortal! Simon has called his discovery “The Everlasting Vehicle” and saved the vehicle’s DNA.

Links to the game on GiHub:

Original code: https://github.com/simon-tiger/steering-behaviors-evolution

p5.js version: https://simon-tiger.github.io/Game_SteeringBehaviorsEvolution/SteeringBehaviours_EvolutionGame_p5/

Simon writes:

The last time I ran the program is a couple of hours ago. Everything died out, except for one vehicle.

Stats

I have programmed this with a genetic algorithm. They have a DNA with 4 genes.

Attraction/Repulsion to food

Attraction/Repulsion to poison

How far it can see food

How far it can see poison

They also have a health, which goes down over time. If they eat food, then their health goes up, if they eat poison, then their health suddenly goes down. A good health is 1, and a bad one is 0.

So what was The Everlasting Vehicle’s DNA and health?

Property Value

Attraction/Repulsion to food 1.9958444373034823

Attraction/Repulsion to poison 1.3554737395594456

How far it can see food 53.31017416626768

How far it can see poison 23.33902221893798

Average health ~397

So it attracts to poison, yet its health is approximately 397 times bigger than a very good health! And better yet, it even lasted for a couple of hours so far!!!

Credits:

Inspired by Daniel Shiffman’s Evolutionary Steering Behaviors Coding Challenge

Link to the Challenge: https://www.youtube.com/watch?v=flxOkx0yLrY

# Simon speaking at the Processing Community Day in Amsterdam

Simon had his first public performance in front of a large audience last Saturday (February 9, 2019): he spoke about his Times Tables Visualization project at the Processing Community Day in Amsterdam!

Simon writes: **You can access the code of the poster and the animation (and the logo for my upcoming company!) and download the presentation in PowerPoint, on GitHub at** **https://github.com/simon-tiger/times_tables**

**If you’d like to buy a printed copy of the poster, please contact me and I’ll send you one. Status: 3 LEFT.**

# Simon’s code for an intriguing problem from the 3Blue1Brown math channel

The number of collisions between two objects equals a number of digits of Pi. The code on GitHub: https://github.com/simon-tiger/Pool_Pi

Simon writes:

From where I got this

I called this sketch Pool_pi because the original paper about this (written in 2003) was called something like Pi in Pool. I learned about this from a recent 3Blue1Brown series:

1st video: https://www.youtube.com/watch?v=HEfHFsfGXjs

2nd video: https://www.youtube.com/watch?v=jsYwFizhncE

3rd video: [not out yet]

The idea

The idea is 2 blocks on a frictionless surface. One slides towards the other, that is facing a wall. All collisions are perfectly elastic.

If the two blocks have the same mass, you can quickly calculate that there will be 3 collisions.

If the one block is 100x the other, it just so happens that there will be 31 collisions.

If the one block is 10000x the other, there will be 314 collisions (I get tired of making graphics). If the one block is 1000000x the other, there will be 3141 collisions.

That’s pi!

The issue!

In my own code, I first used Box2D.

It worked for mass ratios of 1 and 100, but it didn’t work for 10000.

Then I started writing my own physics engine, hoping to fix this issue. But it was even worse.

I couldn’t even get 100 to work.

Then I figured that the blocks are colliding too frequently. So I slowed the 1st block down.

I could get 100 to work this way, but not 10000.

Can anybody help to fix this issue?

I borrowed part of the code from here: https://processing.org/examples/circlecollision.html

# Simon’s Times Tables Visualization is Now a Huge Poster!

Simon has made an enormous poster from his earlier animated version of the Times Tables Visualization! Simon is hoping to present this project at the Processing Community Day in Amsterdam in January 2019. The poster is already being printed!

Simon writes: This is a visualization for the times tables from 1 to 200.

Start with a circle with 200 points. Label the points from 0-199, then from 200-399, then from 400-599, and so on (you’re labeling the same point several times).

We’ll first do the 2x table. 2×1=2, so we connect 1 to 2. 2×2=4, so we connect 2 to 4, and so on.

2×100=200, where’s the 200? It goes in a circle so 200 is where the 0 is, and now you can keep going. Now you could keep going beyond 199, but actually, you’re going to get the same lines you already had!

For the code in Processing, I mapped the two numbers I wanted to connect up (call them i), which are in between 0 and 200, to a range between 0 and 2π. That gave me a fixed radius (I used 75px) and an angle (call it θ). Then I converted those to x and y by multiplying the radius by cos(θ) for x, and the radius by sin(θ) for y. That gave me a coordinate for each point (and even in between points, so you can do the in between times tables as well!) Then I connect up those coordinates with a line. Now I just do this over and over again, until all points are connected to something.

Unfortunately, Processing can only create and draw on a window that is smaller than a screen. So instead of programming a single 2000px x 4000px poster, I programmed 8 1000px x 1000px pieces. Then I just spliced them together.

Idea: Times Tables, Mandelbrot and the Heart of Mathematics video by Mathologer

Code: by Simon Tiger

Download the animated version here: https://github.com/simon-tiger/times_tables

# Creative Coding Utrecht MeetUp

What a blissful day at Creative Coding Utrecht! Simon also got a chance to show a few of his projects in Processing to a cool and understanding audience!

# Optical Illusions in Processing (Java)

Simon created three optical illusions in Processing (Java) playing with color. For better effect, you can download Simon’s code on GitHub: https://github.com/simon-tiger/colorIllusions

The Part 1 video is about the first two illusions. The third (and the coolest) illusion is in Part 2.

Simon writes:

Illusion 1: A checkerboard with blue and yellow squares, but if you move away from it, you see white.

Illusion 2

Mode 1: A disk with red and green, but when you spin it, it becomes yellow.

Mode 2: A disk with red and cyan, but when you spin it, it disappears.

Illusion 3: A rainbow of colors, but when you pause it from flickering, you only see red, green, and blue.

If Illusion 2 Mode 2 doesn’t work, change the background from 255 to between 128 and 135.

If any of the other illusions don’t work, try doing them on a different screen.

Inspired by Physics Girl videos.

# Simon’s Archimedean Solids Project

Simon is working on a project that will involve constructing the Archimedean solids from paper pieces that he programs in Processing (Java) and prints out. In the previous video, Simon worked out the distance between two points to measure the side length of a pentagon that has the radius of 1 (i.e. the distance between its adjacent vertices if the distance from its center to its vertices is 1). He first made a mistake in his calculation and got a result that would be true for a hexagon, not a pentagon. He then corrected himself and got the value that he thought he could use in the Processing code, but as it turned out, the ratio between the radius and the side length was still not right. We recorded a whole new video full of calculations and playing with the code, and achieved pretty neat results after Simon used the new value in the code, but still not good enough, as Simon wanted to have his pentagons to have the side length of 40 (to match the triangles and the squares he’d already made). Simon later found a solution using a different formula for a polygon with n sides (from trigonometry, defining the radius as the side length over (2sin times 180/n)) and succeeded in getting exactly the pentagons he wanted, with the side equalling 40. See the result here:

https://www.youtube.com/watch?v=f4unEptU3Vs&t=1s

The winning formula:

If you are really into working out the calculations, feel free to check out our frantic attempts here:

# Live Stream #16: Twins Game in Processing and Chapter 6 of Living Code.

Simon’s live stream yesterday had several supportive viewers. Simon started making a game of Twins in Processing (Java) and went on with his JavaScript course Living Code, that is based on Daniel Shiffman’s Nature of Code. He tries to keep his live sessions concise now, no longer than 1,5 hours. Note that in the summer, all the live streams will be in Tuesdays in order not to clash with Daniel Shiffman’s summer schedule.