How to add new rules to golly?
How to add new rules to golly?
I have created an interesting rule that i want to simulated
- MDA
- Posts: 235
- Joined: June 8th, 2026, 12:18 pm
- Location: In Haven (B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-ak)
- Contact:
Re: How to add new rules to golly?
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]
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.
My website (a database of Life objects, WIP).
GlidINT has been released!
GlidINT has been released!
Code: Select all
x = 5, y = 17, rule = B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-akHistory
C$2C$.2C$2C11$.3D$3.D$2.3D!
[[ STOP 72 ]]
Re: How to add new rules to golly?
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.
- MDA
- Posts: 235
- Joined: June 8th, 2026, 12:18 pm
- Location: In Haven (B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-ak)
- Contact:
Re: How to add new rules to golly?
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
My website (a database of Life objects, WIP).
GlidINT has been released!
GlidINT has been released!
Code: Select all
x = 5, y = 17, rule = B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-akHistory
C$2C$.2C$2C11$.3D$3.D$2.3D!
[[ STOP 72 ]]
- I6_I6
- Posts: 999
- Joined: July 26th, 2025, 8:44 pm
- Location: Here, there, somewhere, anywhere, everywhere.
- Contact:
Re: How to add new rules to golly?
Do you have a rule table/a .rule file for your rule? If not, I can make you one if you describe your rule.
Code: Select all
#C [[ THEME Golly ]]
x = 27, y = 15, rule = LifeHistory
8.A$A6.A.A$3A4.BA2B.B2D$3.A4.2B.2B2DB$2.2A2.3B.6B2.3B$2.20B$4.19B$4.2B
C10BD4B$4.2B2C10BD4B$4.B2C11B2D3B$4.13B2D4B$5.12BD3B.B2A$6.13B3.BA.A$
6.3B.B3.B10.A$25.2A!
Re: How to add new rules to golly?
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)
- MDA
- Posts: 235
- Joined: June 8th, 2026, 12:18 pm
- Location: In Haven (B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-ak)
- Contact:
Re: How to add new rules to golly?
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)
Edit (July 3rd, 2026, 9:29 PM): Here's a Pygame program to run patterns using your ruleset:
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()
My website (a database of Life objects, WIP).
GlidINT has been released!
GlidINT has been released!
Code: Select all
x = 5, y = 17, rule = B3-ry4acenqt5eir6-ek/S2-a3-a4nq5aeknr6-akHistory
C$2C$.2C$2C11$.3D$3.D$2.3D!
[[ STOP 72 ]]
-
Disaster16439
- Posts: 331
- Joined: June 30th, 2023, 9:17 am
- Location: Teyvat
Re: How to add new rules to golly?
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)
Code: Select all
x=0,y=0,rule=B34q/S23-k
14b3o$13bo3bo$13b2ob2o9$15bo$15bo$b2o12bo12b2o$obo25bobo$o10b3o3b3o10b
o$obo25bobo$b2o12bo12b2o$15bo$15bo9$13b2ob2o$13bo3bo$14b3o!
[[ LOOP 200 THEME POISON AUTOSTART T 0 PAUSE 0.3 ]]