Page 1 of 1

Magnetic Cells

PostPosted: April 18th, 2014, 4:42 am
by Blablob
Play here.

The other day I was just messing around with some code, trying to experiment with objects that copy themselves over and over again. So I got this simple system working where these "cells" will double every 5/6 of a second and then shoot off in a random direction at a random speed. What I found remarkable about this is that a certain pattern will eventually appear if you can get enough cells to spawn; the cells will seem to pull each other together just before they spawn again.

Here's what it looks like:

Image

Like I said, the speed and directions are completely random, and yet the pattern still exists. Strange but intriguing. Try for yourself. If the earlier cells disappear, just refresh the page.

If you want to know why this happens, read on:
Spoiler: show
The speeds can only be defined as integers from -5 to 4. Meanwhile, the directions are based on the x and y speeds that the cell is defined with. So while they are random, each cell only has 100 possible directions/speeds it can travel, which means that at any given point (in this case, every 5/6 of a second), there are only 100 possible positions that a cell can be at. Not too remarkable anymore, is it? Still, it's pretty cool to discover these kinds of things.