Re: Thread for your script-related questions
Posted: March 16th, 2020, 3:13 am
Is there any Golly script around that finds methuselahs?
Forums for Conway's Game of Life
https://conwaylife.com/forums/
Nobody here can help you if you don't give us a lot more information about what isn't working. Which program are you trying to run? which version of the code do you have? What is your operating system and development environment? Which compiler are you using? What command did you try to run? What are the error messages you got?
Which particular utility are you trying to run?Any exe files for spaceship searches?
Again, which script are you trying to run? While Golly seems to be slowly moving towards primarily lua support, there's a lot more Golly scripts available in Python as well as a lot of libraries already easily available for Python too.... or lua that works the same with golly?
There is no fullly featured dedicated methuselah finding Golly script that I am aware of. This post by dvgrn is probably still relevant.
Code: Select all
Peer-reviewing hauls:
Internet does not exist; henceforth trying catagolue.appspot.com instead of gol.hatsya.co.uk...
No response!
Authentication failed.
Received no response from /verify.
Peer-review complete; proceeding search.Code: Select all
#C Matthias Merzenich, 2011
x = 26, y = 31, rule = B2/S13678
7b3o6b3o$o6b4o4b4o6bo$3bo2bo12bo2bo$4o2b2o3b4o3b2o2b4o$b2o4bo4b2o4bo4b
2o$11bo2bo$9bobo2bobo$10bo4bo$9bo2b2o2bo$11bo2bo$8b2o6b2o2$3bo2bo12bo
2bo$7bo4b2o4bo2$bo4bo12bo4bo$4bobobo8bobobo$6bo12bo$3bo2bo12bo2bo$4bo
6bo2bo6bo$6bo12bo$6bo3bob2obo3bo$6b3o8b3o$6b3obo4bob3o2$5b4o8b4o$3b2ob
2o4b2o4b2ob2o$3b2o16b2o2$3b2o16b2o$3b2o16b2o!
WLS and JLS are probably the best programs available for this kind of search, although neither of them support INT rules. For INT rules, rlifesrc seems to work, but is quite a bit slower.LaundryPizza03 wrote: April 18th, 2020, 10:37 am Which programs can find photons with period greater than 1? Particularly ones like this that are too big for LLS.If it can support non-totalistic rules, that would be great, too, but not yet necessary. (I'm trying to find a p3 photon in B25/S136.)Code: Select all
rle
Not only a bit slower, but also returns p1 photons that is pretty annoying.A for awesome wrote: April 18th, 2020, 10:44 amWLS and JLS are probably the best programs available for this kind of search, although neither of them support INT rules. For INT rules, rlifesrc seems to work, but is quite a bit slower.LaundryPizza03 wrote: April 18th, 2020, 10:37 am Which programs can find photons with period greater than 1? Particularly ones like this that are too big for LLS.If it can support non-totalistic rules, that would be great, too, but not yet necessary. (I'm trying to find a p3 photon in B25/S136.)Code: Select all
rle
Sort of possible, but not really. We could build printers that take an expanded Blockic pattern and shrink them down during the print process, to reduce the spacing between them to the point where they will function as Blockic seed constellations for arbitrary objects.otismo wrote: April 19th, 2020, 1:02 amcould a script be made to transpose blockic seeds so they could be printed by GilGil's printer ?
could the printers be modified ?
is it possible ?
"Exact format" depends on whether the pattern that has previously been copied to the clipboard is two-state or multistate. It's also significantly different between Lua and Python. Python sample code:EvinZL wrote: April 18th, 2020, 5:21 pm What is the exact format that golly's g.getclip() outputs in?
Lua and python please
I want python because my programming native language is python
I want lua because I don't want to install python 2
Code: Select all
import golly as g
r = g.getrect()
g.select(r)
g.copy()
clip = g.getclip()
g.setclipstr(str(clip))Code: Select all
local g = golly()
local r = g.getrect()
g.select(r)
g.copy()
x, y, clip = g.getclip()
local s = ""
for k, v in pairs(clip) do
s = s .. v .. "," -- concatenate values in key/value pairs
end
s=s:sub(1,string.len(s)-1)
g.setclipstr(x..","..y..",{"..s.."}")Code: Select all
x = 4, y = 5, rule = B3/S23
bo$2bo$3o2$3bo!Code: Select all
Python:
[4, 5, 1, 0, 2, 1, 0, 2, 1, 2, 2, 2, 3, 4]
Lua:
4,5,{1,0,2,1,0,2,1,2,2,2,3,4}Code: Select all
x = 4, y = 5, rule = LifeHistory
.A$2.A$3A2$3.C!Code: Select all
Python:
[4, 5, 1, 0, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 2, 1, 3, 4, 3, 0]
Lua:
4,5,{1,0,1,2,1,1,0,2,1,1,2,1,2,2,1,3,4,3,0}Start by deciding whether the detection code in the Python version 1.x of apgsearch is good enough for what you need. It produces some kind of (usually) unique identifier for rakes and puffers, anyway, even though I think it's based on the periodicity of the population rather than the actual pattern, so the pattern's period might be twice the number reported in some cases.lemon41625 wrote: April 21st, 2020, 8:38 am How would I go about writing a script to detect and identify period and speed of patterns such as rakes, puffers, breeders and replicators?
Specifically it's the linearlyse function which detects and analyses periodic growth patterns. It can be readily incorporated into other search and CA programs, you can see another example of it's usage in a script I wrote to search for linear growth (It's suboptimal in many ways but hopefully useful to see how it can be used) https://drive.google.com/open?id=1ay2xW ... BPL3RP2ecydvgrn wrote: April 21st, 2020, 9:10 amStart by deciding whether the detection code in the Python version 1.x of apgsearch is good enough for what you need. It produces some kind of (usually) unique identifier for rakes and puffers, anyway, even though I think it's based on the periodicity of the population rather than the actual pattern, so the pattern's period might be twice the number reported in some cases.lemon41625 wrote: April 21st, 2020, 8:38 am How would I go about writing a script to detect and identify period and speed of patterns such as rakes, puffers, breeders and replicators?
Btw, I really like your work on CAViewer, I just haven't taken the time to have a good look at it yet and so I haven't responded to your thread.wildmyron wrote: October 31st, 2017, 12:20 am Alternatively the search could just look for linear growth of any kind. I haven't attempted something like this because I haven't really had a strong desire to find any particular category of linear growth. It seems to me that there are several design considerations in doing this to give a program which does something that apgsearch doesn't already do. First off, what is the search space? How do you want to constrain the search so that explosive rules don't bog it down, but the search will still find interesting results. Then you have to determine the method to detect linear growth when it happens. One option for this is readily available - the linearlyse() function from apgsearch (along with the deepperiod() function).
It's certainly possible to cobble together a script which will find something, even if it isn't particularly performant. Here's a brief outline:
- set up the search paramaters
- candidate pattern (or patterns)
- candidate rule (or rulespace)
- test run parameters (how long to run pattern, max period, etc.)
- inside a loop:
- Initialise layer with candidate rule and pattern
- run pattern for fixed gen
- call linearlyse()
- test the return value - if it starts with 'y' then break out of the loop
- restore layer to state with initial pattern and rule which resulted in linear growth
Code: Select all
uint64_t backdrop[49] = {};
for (int i = 0; i < 512; i++) {
uint8_t a = currstack[(i & 3) | ((i >> 1) & 12)];
uint8_t b = currstack[((i >> 1) & 3) | ((i >> 2) & 12)];
uint8_t c = currstack[((i >> 3) & 3) | ((i >> 4) & 12)];
uint8_t d = currstack[((i >> 4) & 3) | ((i >> 5) & 12)];
backdrop[7*a + b] |= (1ull << (7*c + d));
}
Code: Select all
bool invalid = false;
invalid = invalid || ((focus & 1) && (currstack[focus] == currstack[focus - 1]));
invalid = invalid || ((focus & 2) && (currstack[focus] == currstack[focus - 2]));
invalid = invalid || ((focus & 4) && (currstack[focus] == currstack[focus - 4]));
invalid = invalid || ((focus & 8) && (currstack[focus] == currstack[focus - 8]));
Code: Select all
se = [0,0,0,1,0,2,1,1,1,4,2,5,3,2,3,4]Code: Select all
x = 22, y = 22, rule = B/S012345678
bo18bo$ob18obo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo
$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo$bo18bo
$ob18obo$bo18bo!
Code: Select all
x = 23, y = 23, rule = B/S012345678
bo19bo$ob19obo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19b
o$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19bo$bo19b
o$bo19bo$ob19obo$bo19bo!
Code: Select all
# Rule computation script for use with Golly.
# Author: Nathaniel Johnston (nathaniel@nathanieljohnston.com), June 2009.
# Updated by: Peter, NASZVADI (), June 2017.
# Gives the maximal family of rules that a still life, oscillator, or spaceship
# works under. Must be called while the rule is set of one such family
# For example, to find out what rules a glider works in, first set the rule
# to Life or HighLife, not Seeds.
# Handles nontotalistic rules, too, so it needs Golly 2.8 or newer.
import golly as g
from glife import validint
from string import replace
Hensel = [
['0'],
['1c', '1e'],
['2a', '2c', '2e', '2i', '2k', '2n'],
['3a', '3c', '3e', '3i', '3j', '3k', '3n', '3q', '3r', '3y'],
['4a', '4c', '4e', '4i', '4j', '4k', '4n', '4q', '4r', '4t', '4w', '4y', '4z'],
['5a', '5c', '5e', '5i', '5j', '5k', '5n', '5q', '5r', '5y'],
['6a', '6c', '6e', '6i', '6k', '6n'],
['7c', '7e'],
['8']
]
# Python versions < 2.4 don't have "sorted" built-in
try:
sorted
except NameError:
def sorted(inlist):
outlist = list(inlist)
outlist.sort()
return outlist
# --------------------------------------------------------------------
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i+n]
# --------------------------------------------------------------------
def rulestringopt(a):
result = ''
context = ''
lastnum = ''
lastcontext = ''
for i in a:
if i in 'BS':
context = i
result += i
elif i in '012345678':
if (i == lastnum) and (lastcontext == context):
pass
else:
lastcontext = context
lastnum = i
result += i
else:
result += i
result = replace(result, '4aceijknqrtwyz', '4')
result = replace(result, '3aceijknqry', '3')
result = replace(result, '5aceijknqry', '5')
result = replace(result, '2aceikn', '2')
result = replace(result, '6aceikn', '6')
result = replace(result, '1ce', '1')
result = replace(result, '7ce', '7')
return result
clist = []
rule = g.getrule().split(':')[0]
fuzzer = rule + '9'
oldrule = rule
rule = ''
context = ''
deletefrom = []
for i in fuzzer:
if i == '-':
deletefrom = [x[1] for x in Hensel[int(context)]]
elif i in '0123456789/S':
if deletefrom:
rule += ''.join(deletefrom)
deletefrom = []
context = i
if len(deletefrom) == 0:
rule += i
elif i in deletefrom:
deletefrom.remove(i)
rule = rule.strip('9')
if not (rule[0] == 'B' and '/S' in rule):
g.exit('Please set Golly to a Life-like rule.')
if g.empty():
g.exit('The pattern is empty.')
s = g.getstring('Enter the period:', '', 'Rules calculator')
if not validint(s):
g.exit('Bad number: %s' % s)
numsteps = int(s)
if numsteps < 1:
g.exit('Period must be at least 1.')
g.select(g.getrect())
g.copy()
s = int(s)
for i in range(0,s):
g.run(1)
clist.append(list(chunks(g.getcells(g.getrect()), 2)))
mcc = min(clist[i])
clist[i] = [[x[0] - mcc[0], x[1] - mcc[1]] for x in clist[i]]
g.show('Processing...')
ruleArr = rule.split('/')
ruleArr[0] = ruleArr[0].lstrip('B')
ruleArr[1] = ruleArr[1].lstrip('S')
b_need = []
b_OK = []
s_need = []
s_OK = []
context = ''
fuzzed = ruleArr[0] + '9'
for i in fuzzed:
if i in '0123456789':
if len(context) == 1:
b_need += Hensel[int(context)]
b_OK += Hensel[int(context)]
context = i
elif context != '':
b_need.append(context[0] + i)
b_OK.append(context[0] + i)
context += context[0]
context = ''
fuzzed = ruleArr[1] + '9'
for i in fuzzed:
if i in '0123456789':
if len(context) == 1:
s_need += Hensel[int(context)]
s_OK += Hensel[int(context)]
context = i
elif context != '':
s_need.append(context[0] + i)
s_OK.append(context[0] + i)
context += context[0]
for i in [iter2 for iter1 in Hensel for iter2 in iter1]:
if not i in b_OK:
b_OK.append(i)
execfor = 1
# B0 and nontotalistic rulestrings are mutually exclusive
try:
g.setrule(rulestringopt('B' + ''.join(b_OK) + '/S' + ruleArr[1]))
except:
b_OK.remove(i)
execfor = 0
for j in range(0, s * execfor):
g.run(1)
try:
dlist = list(chunks(g.getcells(g.getrect()), 2))
mcc = min(dlist)
dlist = [[x[0] - mcc[0], x[1] - mcc[1]] for x in dlist]
if not(clist[j] == dlist):
b_OK.remove(i)
break
except:
b_OK.remove(i)
break
g.new('')
g.paste(0, 0, 'or')
g.select(g.getrect())
b_OK.sort()
if not i in s_OK:
s_OK.append(i)
execfor = 1
# B0 and nontotalistic rulestrings are mutually exclusive
try:
g.setrule(rulestringopt('B' + ruleArr[0] + '/S' + ''.join(s_OK)))
except:
s_OK.remove(i)
execfor = 0
for j in range(0, s * execfor):
g.run(1)
try:
dlist = list(chunks(g.getcells(g.getrect()), 2))
mcc = min(dlist)
dlist = [[x[0] - mcc[0], x[1] - mcc[1]] for x in dlist]
if not(clist[j] == dlist):
s_OK.remove(i)
break
except:
s_OK.remove(i)
break
g.new('')
g.paste(0, 0, 'or')
g.select(g.getrect())
s_OK.sort()
if i in b_need:
b_need.remove(i)
g.setrule(rulestringopt('B' + ''.join(b_need) + '/S' + ruleArr[1]))
for j in range(0, s):
g.run(1)
try:
dlist = list(chunks(g.getcells(g.getrect()), 2))
mcc = min(dlist)
dlist = [[x[0] - mcc[0], x[1] - mcc[1]] for x in dlist]
if not(clist[j] == dlist):
b_need.append(i)
break
except:
b_need.append(i)
break
g.new('')
g.paste(0, 0, 'or')
g.select(g.getrect())
b_need.sort()
if i in s_need:
s_need.remove(i)
g.setrule(rulestringopt('B' + ruleArr[0] + '/S' + ''.join(s_need)))
for j in range(0, s):
g.run(1)
try:
dlist = list(chunks(g.getcells(g.getrect()), 2))
mcc = min(dlist)
dlist = [[x[0] - mcc[0], x[1] - mcc[1]] for x in dlist]
if not(clist[j] == dlist):
s_need.append(i)
break
except:
s_need.append(i)
break
g.new('')
g.paste(0, 0, 'or')
g.select(g.getrect())
s_need.sort()
g.setrule(oldrule)
ruleres = 'B' + ''.join(sorted(b_need)) + '/S' + ''.join(sorted(s_need)) + \
' - B' + ''.join(sorted(b_OK)) + '/S' + ''.join(sorted(s_OK))
ruleres = rulestringopt(ruleres)
g.show(ruleres)I'm not sure if that works with replicators.