How to add new rules to golly?
Posted: July 3rd, 2026, 9:16 am
I have created an interesting rule that i want to simulated
Forums for Conway's Game of Life
https://conwaylife.com/forums/
If you want to simulate a rule in Golly, first you need to tell me what kind of rule you want to simulate.plurb wrote: July 3rd, 2026, 9:16 am I have created an interesting rule that i want to simulated [sic]
the rule uses different neighbourhoods for different cells, some use Moore and others use neumannMDA wrote: July 3rd, 2026, 9:43 amIf you want to simulate a rule in Golly, first you need to tell me what kind of rule you want to simulate.plurb wrote: July 3rd, 2026, 9:16 am I have created an interesting rule that i want to simulated [sic]
Is your rule simulated on
- A Moore neighborhood (eight cells in a ring around the center cell)?
- A hexagonal neighborhood (six cells in a hexagon around the center cell)?
- A von Neumann neighborhood (four cells in a diamond around the center cell)?
- A Larger than Life neighborhood (long-range neighborhoods around a center cell)?
Also, if you want to ask such a question, it is better to ask it here than to create a new thread about it.
It would be easier if you told me what the rule is supposed to do.plurb wrote: July 3rd, 2026, 1:15 pm
[…]
the rule uses different neighbourhoods for different cells, some use Moore and others use neumann
Do you have a rule table/a .rule file for your rule? If not, I can make you one if you describe your rule.
the rules are:
In that case, it wouldn’t be possible to do this in Golly. However, I can write a Python script to simulate your rule on a 200x200 grid. Once it’s ready, I’ll edit my post with it.plurb wrote: July 3rd, 2026, 3:58 pm
[…]
the rules are:
1. Cells can have energy from -Infinity to Infinity.
2. Cells with 9 or more energy will give one energy to its 8 neighbours and take 8 energy from itself. (Moore)
3. Cells with -4 or less energy or 5 energy will take one energy from its 4 neighbours and add 4 to itself. (Neumann)
Code: Select all
import pygame
import random
world = []
cursorpos = [100, 100]
buffer = ""
for y in range(0, 200):
world.append([0] * 200)
def makeworld(rle): # Assists in the conversion of an RLE to a matrix
rlel = list(rle)
mat = []
for y in range(0, 200):
mat.append([])
for x in range(0, 200):
mat[-1].append(0)
digits = "0123456789"
y = 0
x = 0
num = 0
for char in rlel:
if char in digits:
num = num * 10 + int(char)
else:
if char == "b":
if num == 0:
num2 = 1
else:
num2 = num
for n in range(0, num2):
mat[x][y] = 0
x += 1
if char == "o":
if num == 0:
num2 = 1
else:
num2 = num
for n in range(0, num2):
mat[x][y] = 1
x += 1
if char == "$":
x = 0
if num == 0:
num2 = 1
else:
num2 = num
for n in range(0, num2):
y += 1
num = 0
return(mat)
def makerle(mat): # Does the opposite of the previous function
rlel = []
num = 1
for row in mat:
for cell in row:
if cell == 0:
rlel.append("b")
else:
rlel.append("o")
rlel.append("$")
rlel[len(rlel) - 1] = "!"
listinit = rlel
rle = "".join(listinit)
return(rle)
# rle = input("RLE (must be headerless, may be empty): ")
# world = makeworld(rle)
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
rectworld = []
for y in range(0, 200):
rectworld.append([])
for x in range(0, 200):
rectworld[-1].append(pygame.Rect(y * 5, x * 5, 5, 5))
clock = pygame.time.Clock()
step = 0
running = True
dt = 0
def advance(world):
global sconds
next = []
for y in range(0, 200):
next.append([])
for x in range(0, 200):
next[-1].append(0)
neigh1 = [[1, 1], [1, 0], [1, -1], [0, 1], [0, -1], [-1, 1], [-1, 0], [-1, -1]]
neigh2 = [[1, 0], [0, 1], [0, -1], [-1, 0]]
for y in range(0, 200):
for x in range(0, 200):
for n in range(0, 8):
newx = x + neigh1[n][1]
newy = y + neigh1[n][0]
if newx == 200:
newx = 199
if newx == -1:
newx = 0
if newy == 200:
newy = 199
if newy == -1:
newy = 0
cell = world[y][x]
neighboring = world[newy][newx]
if neighboring >= 9:
next[y][x] += 1
if cell >= 9:
next[y][x] -= 8
if neigh1[n] in neigh2 and neighboring <= -4:
next[y][x] -= 1
if cell <= -4:
next[y][x] += 4
return next
def show(world):
for y in range(0, 200):
for x in range(0, 200):
if world[y][x] > 0:
ratio = 1 - (1 / world[y][x])
r = round(255 * ratio)
g = round(255 * ratio)
b = 0
pygame.draw.rect(screen, (r, g, b), rectworld[y][x])
if world[y][x] < 0:
ratio = 1 + (1 / world[y][x])
r = 0
g = 0
b = round(255 * ratio)
# print(r, g, b)
pygame.draw.rect(screen, (r, g, b), rectworld[y][x])
if y == cursorpos[0] and x == cursorpos[1] and world[y][x] > 0:
ratio = 1 - (1 / world[y][x])
r = round(((255 * ratio) + 255) / 2)
g = round(255 * ratio)
b = 0
pygame.draw.rect(screen, (r, g, b), rectworld[y][x])
if y == cursorpos[0] and x == cursorpos[1] and world[y][x] < 0:
ratio = 1 + (1 / world[y][x])
r = 128
g = 0
b = round(255 * ratio)
# print(r, g, b)
if y == cursorpos[0] and x == cursorpos[1] and world[y][x] == 0:
pygame.draw.rect(screen, "maroon", rectworld[y][x])
def randfill():
global world
for y in range(68, 132):
for x in range(68, 132):
world[y][x] = round((1 / random.random()) * random.randint(-1, 1))
return world
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
running = False
if event.key == pygame.K_r:
world = randfill()
if event.key == pygame.K_c:
print(makerle(world))
buffer = makerle(world)
if event.key == pygame.K_v:
world = makeworld(buffer)
if event.key == pygame.K_TAB:
world = advance(world)
if event.key == pygame.K_UP:
cursorpos[1] -= 1
cursorpos[1] %= 200
if event.key == pygame.K_DOWN:
cursorpos[1] += 1
cursorpos[1] %= 200
if event.key == pygame.K_LEFT:
cursorpos[0] -= 1
cursorpos[0] %= 200
if event.key == pygame.K_RIGHT:
cursorpos[0] += 1
cursorpos[0] %= 200
if event.key == pygame.K_RETURN:
world[cursorpos[0]][cursorpos[1]] += 1
world[cursorpos[0]][cursorpos[1]] %= 2
if event.key == pygame.K_EQUALS:
world[cursorpos[0]][cursorpos[1]] += 1
if event.key == pygame.K_MINUS:
world[cursorpos[0]][cursorpos[1]] -= 1
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
world = advance(world)
if keys[pygame.K_w]:
cursorpos[1] -= 1
cursorpos[1] %= 200
if keys[pygame.K_s]:
cursorpos[1] += 1
cursorpos[1] %= 200
if keys[pygame.K_a]:
cursorpos[0] -= 1
cursorpos[0] %= 200
if keys[pygame.K_d]:
cursorpos[0] += 1
cursorpos[0] %= 200
screen.fill("black")
show(world)
pygame.display.flip()
dt = clock.tick(60) / 1000
pygame.quit()
It might be possible to simulate this in golly, but I need to know one detail: in what order do you simulate the cells? This isn’t like a normal CA, since there you can simulate all at once.plurb wrote: July 3rd, 2026, 3:58 pmthe rules are:
1. Cells can have energy from -Infinity to Infinity.
2. Cells with 9 or more energy will give one energy to its 8 neighbours and take 8 energy from itself. (Moore)
3. Cells with -4 or less energy or 5 energy will take one energy from its 4 neighbours and add 4 to itself. (Neumann)