Ulam Spiral in GoL?

For discussion of specific patterns or specific families of patterns, both newly-discovered and well-known.
Post Reply
OHAD
Posts: 16
Joined: March 24th, 2013, 12:43 pm

Ulam Spiral in GoL?

Post by OHAD » March 27th, 2013, 11:51 am

Ulam Spiral is a basic and a simple method of visualizing prime numbers. Mathematicians have programmed it into very big numbers, and the best one I could found online is up to the number 9*10^10 (90 giga pixels). http://www.ulamspiral.com/generatePage.asp?ID=21
You can clearly see a lot of diagonals and interesting patterns in this special ulam spiral, but no one has proved what's special in this.
So, while testing it out to the very big numbers, I was thinking about The Game Of Life, and, those two easily connected- What if we'll take the spiral until a certain level, and run a program that calculates it with the rules of Conway's Game Of Life?
I haven't checked it yet, because it's too hard for me to program those things into golly or an other GoL script, but there's my first thoughts and guesses about it:

1. It doesn't matter how random it seems like, it is not random. I know that math is pure, and pretty much everything can be simplified and explained if we'll do enough researchs. People also thought that the density of primes is random, but a quite simple formula has been found to decribe it (not to 100%. It gets more and more exact when you calculate that on bigger numbers).
2. A very big number of cells will die from lonliness (0-1 cells), while a very small number of cells will die from over-crowding (4+ cells). When we'll get to bigger numbers and go further in the spiral, there will be a bigger percent of lonely cells and a smaller one of over-crowding cells.
3. Oscillators will be pretty rare in here.
4. Still Lives will be a bit more common.
5. Escaping Gliders (and other Spaceships will find) will almost always get destroyed, as more and more cells will get through.

So, I have no way to prove those statements. That's why I'm asking you to run a script and check that. I think that testing it to the bounding box of 500*500 is a good start, but, of course, bigger is better.

User avatar
DivusIulius
Posts: 89
Joined: April 1st, 2009, 11:23 am
Contact:

Re: Ulam Spiral in GoL?

Post by DivusIulius » March 27th, 2013, 7:22 pm

Please find enclosed the Ulam Spiral in GoL script.

Please take note that the script execution time depends on the prime number factorization algorithm, which is pretty sensitive to the value of

Code: Select all

my $boundingBox = 500;
(the size of the bounding box).

Enjoy your fireworks... :wink:

Code: Select all

use strict;

sub primes {
    my @n = (2..shift);
    my @p;
    while (@n && (push @p, shift @n)) {
        @n = grep { $_ % $p[-1] } @n;
    }
    return @p
}

g_new("UlamSpiral");

my $boundingBox = 500; #Input parameter

my @primeArray = primes($boundingBox * $boundingBox); # Find all primes numberse up to "$boundingBox * $boundingBox"
my $nextPrimeIndex = 0; #The index of the first prime number to be written down

my $index = 1; #Iterates over all the cells within the $boundingBox
my $currentArmSize = 1; #As the spiral grows the arms become bigger and bigger
my $repeatArm = 0; #In order to build the spiral we need two successive arms of the same size
my $armIndex = $currentArmSize; #Position within the arm
my $x = 0; #Writing x position
my $y = 0; #Writing y position
my $direction = 0; # 0: left->rigth; 1: down->up; 2: right->left; 3: up->down

g_setcell($x, $y, 0); #Number 1 is not prime

while ($index < ($boundingBox * $boundingBox)) {
	$index++; 
	$armIndex--;

	if ($direction == 0) {
		$x++;
	} elsif ($direction == 1) {
		$y--;
	} elsif ($direction == 2) {
		$x--;
	} elsif ($direction == 3) {
		$y++;
	}

	if (@primeArray[$nextPrimeIndex] == $index) {
		g_setcell ($x, $y, 1);
		$nextPrimeIndex++;
	}

	if ($armIndex == 0) {
		$direction = ($direction + 1) % 4;
		if ($repeatArm == 0) {
			$armIndex = $currentArmSize;
			$repeatArm = ($repeatArm + 1) % 2;
		} else {
			$currentArmSize++;
			$armIndex = $currentArmSize;
			$repeatArm = ($repeatArm + 1) % 2;
		}
	}	
} 

User avatar
DivusIulius
Posts: 89
Joined: April 1st, 2009, 11:23 am
Contact:

Re: Ulam Spiral in GoL?

Post by DivusIulius » March 27th, 2013, 7:32 pm

I forgot to mention that it's a Perl Script for Golly. :wink:

OHAD
Posts: 16
Joined: March 24th, 2013, 12:43 pm

Re: Ulam Spiral in GoL?

Post by OHAD » April 21st, 2013, 1:08 pm

Big news!
I started searching for some interesting material about Ulam Spiral, and I found a website fully to it. It's not that big or has a big amount of material, but I just noticed a flash version of it, with options to change some options (layered composite number filters, inverted colors, size, zooming, etc.). Guess what- it has an option of running game of life on that very pattern!
http://www.ulamspiral.com/generatePage.asp?ID=5#
It lags a lot when I'm testing it on big patterns, so I'm now testing it on 1000 pixels.
Some small conclusions:
*As I expected, most of the cells died in the beginning.
*Most of the survivors stay in a still life form, while a smaller number organize into oscillators and spaceships.
*The patterns themself are as common as expected to be- Blocks are the most common still life, appearing all over the grid, Blinkers are the most common Oscillators are Blinkers and Toads (while Blinkers appear a lot less), and Gliders are the most common Spaceships- the rest haven't been discovered in from this pattern yet.
*All of the Gliders that emerged have "died" for now, while a surprisingly big part of them was eaten in special ways by eaters (mostly Blocks).

If someone has a strong computer, he's willing to try it on his computer with bigger grids. Remember, 1000 pixels is very limiting. I can't see none of the "activity" outside it.

Heck, who knows, we'll might find a new special type of pattern emerging from it!
Just a 13-years old kid.

frances
Posts: 1
Joined: August 8th, 2013, 1:21 am

Re: Ulam Spiral in GoL?

Post by frances » August 8th, 2013, 1:29 am

What are the implications of choosing to have one be a "prime'. Some versions of Ulam spiral have one prime and two not or two prime and one not. I know all the arguments about fundamental theorem of arithmetic etc but are there any profound consequences in the game of life version if one is considered prime and two not?

joannej11
Posts: 2
Joined: January 16th, 2015, 12:03 am

Re: Ulam Spiral in GoL?

Post by joannej11 » January 21st, 2015, 10:32 am

The Ulam spiral, or prime spiral (in other languages also called the Ulam Cloth) is a simple method of visualizing the prime numbers that reveals the apparent tendency of certain quadratic polynomials to generate unusually large numbers of primes. It was discovered by the mathematician Stanislaw Ulam in 1963, while he was doodling during the presentation of a "long and very boring paper" at a scientific meeting.
Joanne

Volkhen
Posts: 1
Joined: May 22nd, 2021, 6:41 pm

Re: Ulam Spiral in GoL?

Post by Volkhen » May 22nd, 2021, 6:43 pm

You might also do a negative of Ulam Spiral in GoL. As primes are quite rare the negative should produce more life in GoL.

Post Reply