Add Periodic Random Noise Input

For general discussion about Conway's Game of Life.
Post Reply
Fencient
Posts: 6
Joined: August 8th, 2020, 12:01 am

Add Periodic Random Noise Input

Post by Fencient » August 8th, 2020, 12:12 am

I need a way to add random noise into the sim every generation, or so. The probability of a pixel getting a "bit flip" should also be controllable.

So for ex: the entire map, a 10% chance that a pixel will flip every generation.

Another ex: the outer 50% edge of the map is noise-free, but as you get closer to the center of the map the noise increases in probability/frequency.

Another ex: noise shocks where the entire map will experience a short period of high noise, but then calm down for a bit.

I think adding noise with the correct frequency/probability/region can potentially create a sort of darwinian evolution in the sim and I really need to see that.

GUYTU6J
Posts: 2200
Joined: August 5th, 2016, 10:27 am
Location: 拆哪!I repeat, CHINA! (a.k.a. 种花家)
Contact:

Re: Add Periodic Random Noise Input

Post by GUYTU6J » August 8th, 2020, 2:25 am

[DATA EXPUNGED]
Last edited by GUYTU6J on September 25th, 2022, 11:51 pm, edited 1 time in total.

User avatar
PushDecimal
Posts: 29
Joined: November 21st, 2018, 4:23 pm

Re: Add Periodic Random Noise Input

Post by PushDecimal » August 8th, 2020, 5:21 am

Nicky Case's emoji simulator seems to be the perfect tool for the first example:
http://ncase.me/sim/?lz=N4IgtgpgLghiBco ... ADxpJBDZAA

Fencient
Posts: 6
Joined: August 8th, 2020, 12:01 am

Re: Add Periodic Random Noise Input

Post by Fencient » August 8th, 2020, 11:51 am

PushDecimal wrote:
August 8th, 2020, 5:21 am
Nicky Case's emoji simulator seems to be the perfect tool for the first example:
http://ncase.me/sim/?lz=N4IgtgpgLghiBco ... ADxpJBDZAA


WOW! That's exactly what mechanism I was talking about. Too bad it's limited to 50x50. Is there anyway to do this in Gully? I need a million by million grid with this.

User avatar
PushDecimal
Posts: 29
Joined: November 21st, 2018, 4:23 pm

Re: Add Periodic Random Noise Input

Post by PushDecimal » August 8th, 2020, 12:48 pm

Python makes it possible.

Code: Select all

import random, golly as g

g.setrule("Life:P1000000,1000000")
try:
	probability = 100/float(g.getstring("Probability (%): "))
except ZeroDivisionError:
	g.exit("No cells will be set.")
except ValueError:
	g.exit("Invalid percentage.")
while True:
	g.step()
	g.update()
	if random.uniform(0, probability) < 1:
		g.setcell(random.randint(-500000,499999), random.randint(-500000,499999), random.getrandbits(1))
This script runs the game with a customisable probability of a cell flipping. Keep in mind that with 1 000 000 000 000 cells, you might never see anything happen.

Fencient
Posts: 6
Joined: August 8th, 2020, 12:01 am

Re: Add Periodic Random Noise Input

Post by Fencient » August 8th, 2020, 1:37 pm

PushDecimal wrote:
August 8th, 2020, 12:48 pm
Python makes it possible.

Code: Select all

import random, golly as g

g.setrule("Life:P1000000,1000000")
try:
	probability = 100/float(g.getstring("Probability (%): "))
except ZeroDivisionError:
	g.exit("No cells will be set.")
except ValueError:
	g.exit("Invalid percentage.")
while True:
	g.step()
	g.update()
	if random.uniform(0, probability) < 1:
		g.setcell(random.randint(-500000,499999), random.randint(-500000,499999), random.getrandbits(1))
This script runs the game with a customisable probability of a cell flipping. Keep in mind that with 1 000 000 000 000 cells, you might never see anything happen.

I don't get it. Nothing happens when I run that script. It asks me for what percent, and then nothing. Other scripts run fine.

Fencient
Posts: 6
Joined: August 8th, 2020, 12:01 am

Re: Add Periodic Random Noise Input

Post by Fencient » August 8th, 2020, 3:45 pm

Here's what works but is really slow:

Code: Select all

# Randomly fill cells in the current selection.
# Author: Andrew Trevorrow (andrew@trevorrow.com), March 2011.

import golly as g
from glife import rect, validint
from time import time
from random import randint

g.autoupdate(True)
r = rect( g.getselrect() )
if r.empty: g.exit("There is no selection.")

maxlive = g.numstates() - 1

# use previous values if they exist
inifilename = g.getdir("data") + "random-fill.ini"
previousvals = "50 1 " + str(maxlive)
try:
   f = open(inifilename, 'r')
   previousvals = f.readline()
   f.close()
except:
   # should only happen 1st time (inifilename doesn't exist)
   pass

result = g.getstring(
   "Enter percentage minstate maxstate values\n" +
   "where the percentage is an integer from 0 to 100\n" +
   "and the state values are integers from 1 to "+str(maxlive)+"\n" +
   "(maxstate is optional, default is minstate):",
   previousvals, "Randomly fill selection")

# save given values for next time this script is called
try:
   f = open(inifilename, 'w')
   f.write(result)
   f.close()
except:
   g.warn("Unable to save given values in file:\n" + inifilename)

# extract and validate values
pmm = result.split()
if len(pmm) == 0: g.exit()
if len(pmm) == 1: g.exit("You must supply min and max states.")
if not validint(pmm[0]): g.exit("Bad percentage value: " + pmm[0])
if not validint(pmm[1]): g.exit("Bad minstate value: " + pmm[1])
perc = int(pmm[0])
minlive = int(pmm[1])
if perc < 0 or perc > 100:
   g.exit("Percentage must be from 0 to 100.")
if minlive < 1 or minlive > maxlive:
   g.exit("Minimum state must be from 1 to "+str(maxlive)+".")
if len(pmm) > 2:
   if not validint(pmm[2]): g.exit("Bad maxstate value: " + pmm[2])
   i = int(pmm[2])
   if i < minlive: g.exit("Maximum state must be >= minimum state.")
   if i > maxlive: g.exit("Maximum state must be <= "+str(maxlive)+".")
   maxlive = i
else:
   maxlive = minlive

i = 0
while i < 50:
   g.step()
   oldsecs = time()
   for row in xrange(r.top, r.top + r.height):
      for col in xrange(r.left, r.left + r.width):
         if randint(0,99) < perc:
            if minlive == maxlive:
               g.setcell(col, row, minlive)
            else:
               g.setcell(col, row, randint(minlive,maxlive))
      # if large selection then give some indication of progress
      newsecs = time()
      if newsecs - oldsecs >= 1.0:
         oldsecs = newsecs
         g.update()
   i += 1
Really needs a branchless solution.

Here's a copy/paste solution, but it's still clunky:

Code: Select all

import random, golly as g

g.autoupdate(True)

while True:
	g.setlayer(0)
	g.randfill(1)
	g.copy()
	g.setlayer(1)
	g.paste(-600, -400, "xor")
	g.run(1)
EDIT: it's been several hours and even though the script is slow, I'm at 35k generations and I believe I have entered the second epoch. If you look at these screenshots, you'll notice distancing between groups. These boundaries used to come and go in a single step, but now they have entrenched themselves and basically don't move anymore. Even more interesting which you can still tell from the stills, is that there seems to be a dichotomy developing. There are large structures that still seem very random and chaotic, but the micros seem to have found a niche between these gaps. What you can't tell from the stills is that these micros are tending towards a cyclic form that goes from small, grows a little, rotates a bit, and then collapses back in on itself. Their structure is almost conceivable. And they tend to not move from their spot, just rotate around it. I also noticed some bits being passed between the "macros" and the "micros". These micros seems to be relays that alleviate and provide pressure to the bombarded macros.

I'm using 1% noise per step and it seems to be a good balance between enough input and selection pressure to select for larger self-repairing structures. I find myself just hypnotized watching this trying to decipher the emerging structures.
Attachments
abiogenesisA-gen35000-1to4scale.png
abiogenesisA-gen35000-1to4scale.png (146.97 KiB) Viewed 2867 times
abiogenesisA-gen35000-1to2scale.png
abiogenesisA-gen35000-1to2scale.png (228.28 KiB) Viewed 2867 times
abiogenesisA-gen35000-1to1scale.png
abiogenesisA-gen35000-1to1scale.png (388.23 KiB) Viewed 2867 times

User avatar
PushDecimal
Posts: 29
Joined: November 21st, 2018, 4:23 pm

Re: Add Periodic Random Noise Input

Post by PushDecimal » August 9th, 2020, 4:11 am

Fencient wrote:
August 8th, 2020, 1:37 pm
I don't get it. Nothing happens when I run that script. It asks me for what percent, and then nothing. Other scripts run fine.
As in, it's not even running the game?

Fencient
Posts: 6
Joined: August 8th, 2020, 12:01 am

Re: Add Periodic Random Noise Input

Post by Fencient » August 9th, 2020, 11:08 am

PushDecimal wrote:
August 9th, 2020, 4:11 am
As in, it's not even running the game?
Yes. I even tried changing it to 1000 by 1000, but still nothing.

Post Reply