Entity Valkyrie wrote:I need lua, not python because I don't have python.
x = 17, y = 10, rule = B3/S23
b2ob2obo5b2o$11b4obo$2bob3o2bo2b3o$bo3b2o4b2o$o2bo2bob2o3b4o$bob2obo5b
o2b2o$2b2o4bobo2b3o$bo3b5ob2obobo$2bo5bob2o$4bob2o2bobobo!
Saka wrote:Entity Valkyrie wrote:I need lua, not python because I don't have python.
Why dont you install python then?
Entity Valkyrie wrote:I did install python 3.7, but it still did't wprk.
Entity Valkyrie wrote:Saka wrote:Entity Valkyrie wrote:I need lua, not python because I don't have python.
Why dont you install python then?
I did install python 3.7, but it still did't wprk.
dvgrn wrote:Only Python 2.7.x works with Golly. Try installing Python 2.7.15 -- and make sure it's 32-bit if you have 32-bit Golly, or 64-bit if you have 64-bit Golly.
Ian07 wrote:dvgrn wrote:Only Python 2.7.x works with Golly. Try installing Python 2.7.15 -- and make sure it's 32-bit if you have 32-bit Golly, or 64-bit if you have 64-bit Golly.
Yeah, forgot about that. Anyway, if it still gives an error, the thing I suggested above should still work - just replace Python37 with Python27.
--This is a preliminary version. If sufficiently interesting behaviours show
--up, it would be nice to get a full simulating algorithm in better-written
--softawre like Golly. Speaking of Golly, make sure you have a version that
--supports Lua, so you can run this script. Stinky.
--TERMS TO KNOW:
--Heat - The number returned when the previous equation is ran on all of the
-- other cells in relation to the given cell (basically what count()
-- does)
local g = golly()
local gp = require "gplus"
local rulesB = {2, 3, 4, 5}
local rulesS = {2, 3, 4, 5}
function count(x1, y1) --determine cell's heat
local pat
local total = 0
if g.getcell(x1, y1) == 1 then --ok i know it's ugly but it saves a lot of processing time than doing a conditional
g.setcell(x1, y1, 0)
pat = g.getcells(g.getrect())
g.setcell(x1, y1, 1)
else
pat = g.getcells(g.getrect())
end
for i = 1, #pat, 2 do
local x2 = pat[i]
local y2 = pat[i+1] --ugly
total = total+1 / ((x2-x1)^2+(y2-y1)^2) --i know i said i was using fourth powers, however the square root and fourth power cancel out leaving just a stray ^2
end
return total
end
function ring(r) --basically, it returns a 'outer moore birth ring' of the given size
local pat = g.getcells(g.getrect())
local x, y, w, h = table.unpack(r) --there a better way to do this?
g.select({x-1, y-1, w+2, h+2})
g.randfill(100)
g.select({x, y, w, h})
g.clear(0)
local ring = g.getcells(g.getrect())
g.putcells(pat)
g.clear(1)
g.select({})
return ring
end
function step()
--hoooo boy i hated writing this
--don't read it if you don't want to get lost
local pat = g.getcells(g.getrect())
local rulesBclone = rulesB
table.sort(rulesBclone)
local minrulesB = rulesBclone[1] --math.min but with an array
local lx, ly, lw, lh = table.unpack(g.getrect())
while true do --this loop determines how far to check for births
local localmax = 0
local localring = ring({lx, ly, lw, lh})
for i = 1, #localring, 2 do
local localcount = count(localring[i], localring[i+1])
if localcount > localmax then
localmax = localcount
end
end
if localmax < minrulesB then
break
end
lx = lx - 1
ly = ly - 1
lw = lw + 2
lh = lh + 2
end
--gosh that took me months to make, now onto processing
g.select({lx, ly, lw, lh})
g.randfill(100)
g.putcells(pat, 0, 0, 1, 0, 0, 1, --[[ugh why]] "xor")
local area = g.getcells(g.getrect())
g.clear(0)
g.putcells(pat)
--NOW LET'S FINALLY PROCESS BIRTH, aka the reason that hellhole of lines above had to be done
for i = 1, #area, 2 do
g.setcell(area[i], area[i+1], 0)
local localcount = count(area[i], area[i+1])
for j = 1, #rulesB, 2 do
if localcount >= rulesB[j] and localcount <= rulesB[j+1] then
g.setcell(area[i], area[i+1], 1)
end
end
end
--and survival, the easy part
for i = 1, #pat, 2 do
g.setcell(pat[i], pat[i+1], 0)
local localcount = count(pat[i], pat[i+1])
for j = 1, #rulesS, 2 do
if localcount >= rulesS[j] and localcount <= rulesS[j+1] then
g.setcell(pat[i], pat[i+1], 1)
end
end
end
end
while true do
step()
g.update()
end
x = 105, y = 46, rule = B3/S23
o71bobobobobobobob12o2bob3o$o65bobo2bobobobobobobobo12bo4b2o$b2o60bo2b
o2bo12bo4bo2bobobobo2bo4bo$59bob2o2bo5bo4bo16bobobo$56bo2bo4bo3bo3bobo
3bobobobo3bobobo5b2o3b2o$54bobo3bo4bo3bo3bobo9bobo6bo5bo3bo$52bobo3bo
2bo2bobo4bo6bo2bobo7bo6bo5bo$51b2o7bobo2bo3bo3bo6bo4bo2bo5bobo7bo$50b
2o2bo4bo3bo2bo4bo2bobobo4bo3bobobobo3bo6bo$51bo6bo5bo2bobo25bo3bo2bobo
$56bo2bobo3bo4bo2bobobobobobobobobo3bo10bo$50b2o5bo8bobo2bo8bo11bo4bob
o4bo$51bo3bo5bo2bo8bobo7bobo4bo3bo4bo4bo$51bo4bo2bo6bo2bobo5bobobo4bob
o4bobobobo4bo$51bo3bobo2bobo2bo17bobo3bo2bo7bo3bo$51bo7bo4bo2bobobo2bo
bobo2bo9bo3bobobo4bo$51bo4bobo3bo12bo6bo4bobo4bo5bo3bo$51bo8bo4bobobob
obo6bo4bo5bo4bo7bo$51bo6bo3bo12bobobo2bobo2bobo3bo5bo4bo$51bobo6bo3bob
obo2bo2bo16bo2bobo3bo3bo$51bo6bo3bo6bo3bo5bobo2bobo3bo6bo6bo$51bo8bo3b
obo9bobo3bo5bo4bo5bo4bo$51bo3bo2bo3bo5bobobobo5bo3bo9bo5bo3bo$51bo4bo
3bo3bobo15bo2bobo2bobo4bo6bo$51bo3bo6bo5bobobo3bobobo2bo9bobo3bo4bo$
51bo6bobo12bo12bobobo9bo3bo$51bo3bo6bo2bo2bo2bo3bo2bo2bo7bo3bobobo6bo$
51bo4bobobo3bobo2bo6bo5bobo14bo4bo$51bo10bo8bo2bo3bobo5bobo3bo3bo3bo3b
o$51bo3bobo2bo2bobobo2bo2bobo7bobo3bobo2bo2bo6bo$51bo9bo6bo3bo7bobo9bo
6bo4bo$51bo5bo4bo2bobo2bo4bobobo7bo9bo6bo$51bobobo3bo3bo9bo8bobo3bobob
obo5bo3bo$51bo4bo11bo2bo8bo5bo10bobo4bo$51bo3bo2bobo2bobobo6bo4bo2bo
10bo2bo7bo$53bo15bobo3bobo7bobobobo8bo3bo$50bobo2bo2bobobo2bobo5bo5bo
2bo10bo4bo5bo$57bo19bo6bo3bo3bobobo3bobobo$50b2o2bo3bobobobobobobo2bob
o2bo2bo3bobobobo3bo2bo4b2o$53bobo5bo5bo6bobo5bo13bo2bo3bo$50b2o4bo22bo
5bo3bo3bo9b2o$53bo18bo31bo$50b2o5bobobobobobobo6bo2bobobo3bo3bobobobo
6bo$51bobo16bobobo11bo11bo2bob2o$50b2ob2obobobobobobobobobob3obobobobo
bobobobobobobobo2bo$51b2obobobobobobobobobobo3bobobobobobobobobobobobo
b2ob2o!
wildmyron wrote:
This looks like your updating during the processing loop, so the neighbourhood for each cell is changing whilst you are processing the results.
danny wrote:Would it work if I instead stored the coordinates of each on cell in a cell list and then placed that after the fact?
--This is a preliminary version. If sufficiently interesting behaviours show
--up, it would be nice to get a full simulating algorithm in better-written
--softawre like Golly. Speaking of Golly, make sure you have a version that
--supports Lua, so you can run this script. Stinky.
--TERMS TO KNOW:
--Heat - The number returned when the previous equation is ran on all of the
-- other cells in relation to the given cell (basically what count()
-- does)
local g = golly()
local gp = require "gplus"
local rulesB = {2, 3, 4, 5}
local rulesS = {2, 3, 4, 5}
function count(x1, y1) --determine cell's heat
local pat
local total = 0
if g.getcell(x1, y1) == 1 then --ok i know it's ugly but it saves a lot of processing time than doing a conditional
g.setcell(x1, y1, 0)
pat = g.getcells(g.getrect())
g.setcell(x1, y1, 1)
else
pat = g.getcells(g.getrect())
end
for i = 1, #pat, 2 do
local x2 = pat[i]
local y2 = pat[i+1] --ugly
total = total+1 / ((x2-x1)^2+(y2-y1)^2) --i know i said i was using fourth powers, however the square root and fourth power cancel out leaving just a stray ^2
end
return total
end
function ring(r) --basically, it returns a 'outer moore birth ring' of the given size
local pat = g.getcells(g.getrect())
local x, y, w, h = table.unpack(r) --there a better way to do this?
g.select({x-1, y-1, w+2, h+2})
g.randfill(100)
g.select({x, y, w, h})
g.clear(0)
local ring = g.getcells(g.getrect())
g.putcells(pat)
g.clear(1)
g.select({})
return ring
end
function step()
--hoooo boy i hated writing this
--don't read it if you don't want to get lost
local pat = g.getcells(g.getrect())
if pat == {} then
g.exit("All cells are dead.")
end
local rulesBclone = rulesB
table.sort(rulesBclone)
local minrulesB = rulesBclone[1] --math.min but with an array
local lx, ly, lw, lh = table.unpack(g.getrect())
while true do --this loop determines how far to check for births
local localmax = 0
local localring = ring({lx, ly, lw, lh})
for i = 1, #localring, 2 do
local localcount = count(localring[i], localring[i+1])
if localcount > localmax then
localmax = localcount
end
end
if localmax < minrulesB then
break
end
lx = lx - 1
ly = ly - 1
lw = lw + 2
lh = lh + 2
end
--gosh that took me months to make, now onto processing
g.select({lx, ly, lw, lh})
g.randfill(100)
g.putcells(pat, 0, 0, 1, 0, 0, 1, --[[ugh why]] "xor")
local area = g.getcells(g.getrect())
g.clear(0)
g.putcells(pat)
--NOW LET'S FINALLY PROCESS BIRTH, aka the reason that hellhole of lines above had to be done
local localcells = {}
for i = 1, #area, 2 do
local localcount = count(area[i], area[i+1])
for j = 1, #rulesB, 2 do
if localcount >= rulesB[j] and localcount <= rulesB[j+1] then
table.insert(localcells, pat[i])
table.insert(localcells, pat[i+1]) --can't think of a way to insert two at once
end
end
end
--and survival, the easy part
for i = 1, #pat, 2 do
local localcount = count(pat[i], pat[i+1])
for j = 1, #rulesS, 2 do
if localcount >= rulesS[j] and localcount <= rulesS[j+1] then
table.insert(localcells, pat[i])
table.insert(localcells, pat[i+1])
end
end
end
g.select(g.getrect())
g.clear(0)
g.putcells(localcells)
g.select({})
g.setgen(tonumber(g.getgen()) + 1)
end
while true do
step()
g.update()
end
danny wrote:I don't think I did it right...
total = total+1 / ((x2-x1)^2+(y2-y1)^2) --i know i said i was using fourth powers, however the square root and fourth power cancel out leaving just a stray ^2
total = total+1 / ((x2-x1)^2+(y2-y1)^2)^2
danny wrote:I hate my spaghetti code ;;
wildmyron wrote:danny wrote:I hate my spaghetti code ;;
Hey, don't worry about it too much - it's not really spaghetti code in my opinion. Some of the calculations you are doing are perhaps a bit convoluted, but once you have a working reference implementation you can clean parts of it up and easily check that it's still working correctly.
x = 0, y = 0, rule = B/S
o100$100bo!
danny wrote:The main optimization I want to make is to make it instead run a tick in B12345678/S012345678, AND it with the pattern (or previous ring), and store that instead...
dvgrn wrote:danny wrote:The main optimization I want to make is to make it instead run a tick in B12345678/S012345678, AND it with the pattern (or previous ring), and store that instead...
To get the list of cells that might be relevant for the next tick, you mean? What if you ran B12345678/S to get the "possible-birth" cells, and just kept the original pattern's cell list for the "possible-survival" cells?
x = 0, y = 0, rule = B12345678/S
o!
--This is a preliminary version. If sufficiently interesting behaviours show
--up, it would be nice to get a full simulating algorithm in better-written
--softawre like Golly. Speaking of Golly, make sure you have a version that
--supports Lua, so you can run this script. Stinky.
--TERMS TO KNOW:
--Heat - The number returned when the previous equation is ran on all of the
-- other cells in relation to the given cell (basically what count()
-- does)
local g = golly()
local gp = require "gplus"
local rulesB = {1.33, 1.7}
local rulesS = {2.5, 5.1}
function count(x1, y1) --determine cell's heat
local pat
local total = 0
if g.getcell(x1, y1) == 1 then --ok i know it's ugly but it saves a lot of processing time than doing a conditional
g.setcell(x1, y1, 0)
pat = g.getcells(g.getrect())
g.setcell(x1, y1, 1)
else
pat = g.getcells(g.getrect())
end
for i = 1, #pat, 2 do
local x2 = pat[i]
local y2 = pat[i+1] --ugly
total = total+1 / ((x2-x1)^2+(y2-y1)^2)^2 --i know i said i was using fourth powers, however the square root and fourth power cancel out leaving just a stray ^2
end
return total
end
function ring(r) --basically, it returns a 'outer moore birth ring' of the given size
local pat = g.getcells(g.getrect())
local x, y, w, h = table.unpack(r) --there a better way to do this?
g.select({x-1, y-1, w+2, h+2})
g.randfill(100)
g.select({x, y, w, h})
g.clear(0)
local nring = g.getcells(g.getrect())
g.putcells(pat)
g.clear(1)
g.select({})
return nring
end
function step()
--hoooo boy i hated writing this
--don't read it if you don't want to get lost
local pat = g.getcells(g.getrect())
if g.getpop() == "0" then
g.exit("All cells are dead.")
return
end
local rulesBclone = rulesB
table.sort(rulesBclone)
local minrulesB = rulesBclone[1] --math.min but with an array
local lx, ly, lw, lh = table.unpack(g.getrect())
while true do --this loop determines how far to check for births
local localmax = 0
local localring = ring({lx, ly, lw, lh})
for i = 1, #localring, 2 do
local localcount = count(localring[i], localring[i+1])
if localcount > localmax then
localmax = localcount
end
end
if localmax < minrulesB then
break
end
lx = lx - 1
ly = ly - 1
lw = lw + 2
lh = lh + 2
end
--gosh that took me months to make, now onto processing
g.select({lx, ly, lw, lh})
g.randfill(100)
g.putcells(pat, 0, 0, 1, 0, 0, 1, --[[ugh why]] "xor")
local area = g.getcells(g.getrect())
g.clear(0)
g.putcells(pat)
--NOW LET'S FINALLY PROCESS BIRTH, aka the reason that hellhole of lines above had to be done
local localcells = {}
for i = 1, #area, 2 do
local localcount = count(area[i], area[i+1])
for j = 1, #rulesB, 2 do
if localcount >= rulesB[j] and localcount <= rulesB[j+1] then
table.insert(localcells, area[i])
table.insert(localcells, area[i+1]) --can't think of a way to insert two at once
end
end
end
--and survival, the easy part
for i = 1, #pat, 2 do
local localcount = count(pat[i], pat[i+1])
for j = 1, #rulesS, 2 do
if localcount >= rulesS[j] and localcount <= rulesS[j+1] then
table.insert(localcells, pat[i])
table.insert(localcells, pat[i+1])
end
end
end
g.select(g.getrect())
g.clear(0)
g.putcells(localcells)
g.select({})
g.setgen(tonumber(g.getgen())+1)
end
while true do
step()
g.update()
end
step()
x = 4, y = 4, rule = B/S012345678
3bo$2b2o$bobo$3o!
x = 3, y = 3, rule = B/S012345678
2o$3o$2bo!
x = 3, y = 7000, rule = B/S012345678
2o$3o$2bo2$2bo$3o$2o!
--This is a preliminary version. If sufficiently interesting behaviours show
--up, it would be nice to get a full simulating algorithm in better-written
--software like Golly. Speaking of Golly, make sure you have a version that
--supports Lua, so you can run this script. Stinky.
--TERMS TO KNOW:
--Heat - The number returned when the previous equation is ran on all of the
-- other cells in relation to the given cell (basically what count()
-- does)
local g = golly()
local gp = require "gplus"
local prompt = [[
Enter birth and survival (e.g. 2,3,4,5 2,3,4,5):
]]
local answer = g.getstring(prompt, "2,3,4,5 2,3,4,5", "Set Rule...")
local birth, survival = gp.split(answer)
local rulesB = {gp.split(birth, ",")}
local rulesS = {gp.split(survival, ",")}
for i = 1, #rulesB do
rulesB[i] = tonumber(rulesB[i])
end
for j = 1, #rulesS do
rulesS[j] = tonumber(rulesS[j])
end
function count(x1, y1) --determine cell's heat
local pat
local total = 0
if g.getcell(x1, y1) == 1 then --ok i know it's ugly but it saves a lot of processing time than doing a conditional
g.setcell(x1, y1, 0)
pat = g.getcells(g.getrect())
g.setcell(x1, y1, 1)
else
pat = g.getcells(g.getrect())
end
for i = 1, #pat, 2 do
local x2 = pat[i]
local y2 = pat[i+1] --ugly
total = total+1 / ((x2-x1)^2+(y2-y1)^2)^2 --i know i said i was using fourth powers, however the square root and fourth power cancel out leaving just a stray ^2
end
return total
end
function ring(r) --basically, it returns a 'outer moore birth ring' of the given size
local pat = g.getcells(g.getrect())
local x, y, w, h = table.unpack(r) --there a better way to do this?
g.select({x-1, y-1, w+2, h+2})
g.randfill(100)
g.select({x, y, w, h})
g.clear(0)
local nring = g.getcells(g.getrect())
g.putcells(pat)
g.clear(1)
g.select({})
return nring
end
function step()
--hoooo boy i hated writing this
--don't read it if you don't want to get lost
local pat = g.getcells(g.getrect())
if g.getpop() == "0" then
g.exit("All cells are dead.")
return
end
local rulesBclone = rulesB
table.sort(rulesBclone)
local minrulesB = rulesBclone[1] --math.min but with an array
local lx, ly, lw, lh = table.unpack(g.getrect())
while true do --this loop determines how far to check for births
local localmax = 0
local localring = ring({lx, ly, lw, lh})
for i = 1, #localring, 2 do
local localcount = count(localring[i], localring[i+1])
if localcount > localmax then
localmax = localcount
end
end
if localmax < minrulesB then
break
end
lx = lx - 1
ly = ly - 1
lw = lw + 2
lh = lh + 2
end
--gosh that took me months to make, now onto processing
g.select({lx, ly, lw, lh})
g.randfill(100)
g.putcells(pat, 0, 0, 1, 0, 0, 1, --[[ugh why]] "xor")
local area = g.getcells(g.getrect())
g.clear(0)
g.putcells(pat)
--NOW LET'S FINALLY PROCESS BIRTH, aka the reason that hellhole of lines above had to be done
local localcells = {}
for i = 1, #area, 2 do
local localcount = count(area[i], area[i+1])
for j = 1, #rulesB, 2 do
if localcount >= rulesB[j] and localcount <= rulesB[j+1] then
table.insert(localcells, area[i])
table.insert(localcells, area[i+1]) --can't think of a way to insert two at once
end
end
end
--and survival, the easy part
for i = 1, #pat, 2 do
local localcount = count(pat[i], pat[i+1])
for j = 1, #rulesS, 2 do
if localcount >= rulesS[j] and localcount <= rulesS[j+1] then
table.insert(localcells, pat[i])
table.insert(localcells, pat[i+1])
end
end
end
g.select(g.getrect())
g.clear(0)
g.putcells(localcells)
g.select({})
g.setgen(tonumber(g.getgen())+1)
end
while true do
step()
g.update()
end
step()
x = 1, y = 1, rule = B1e2ak3einqy4jnry5einqy6ak7e/S1e2ak3einqy4jnry5einqy6ak7e
o!
x = 1, y = 1, rule = B1e2ak3einqy4jnry5einqy6ak7e/S01c2-ak3acjkr4-jnry5acjkr6-ak7c8
o!
muzik wrote:The Fredkin rule generation script outputs rules rules that replicate similarly to this one...Code: Select all(replication of one dot into four increasingly widely separated dots)
Could it be modified to also be able to create (multi state generalisations of) rules similar to the following, where the center is preserved while still allowing replication overall (giving a core rule of 150 for 2-state versions)?
x = 1, y = 1, rule = B1357/S1357
o!
x = 1, y = 1, rule = B1357/S02468
o!
Users browsing this forum: No registered users and 2 guests