[Rule]Investigator support in Golly

For general discussion about Conway's Game of Life.
User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

[Rule]Investigator support in Golly

Post by rowett » September 19th, 2023, 10:20 am

I've added [Rule]Investigator support to Golly. It will appear in the next release.

I've added basic documentation to the relevant Help page but would welcome enhancements to this! The relevant file is: Help/Algorithms/Super.html.

If you don't have access to SourceForge where Golly lives then feel free to send me any updates and I'll add them.

Finally, I'd also welcome any good example [Rule]Investigator patterns.

User avatar
b3s23love
Posts: 97
Joined: May 24th, 2023, 6:30 am
Location: The (Life?) Universe

Re: [Rule]Investigator support in Golly

Post by b3s23love » September 19th, 2023, 10:48 am

rowett wrote:
September 19th, 2023, 10:20 am
Finally, I'd also welcome any good example [Rule]Investigator patterns.
Maybe add the official RLE for explaining the cell states?

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » September 19th, 2023, 1:46 pm

b3s23love wrote:
September 19th, 2023, 10:48 am
rowett wrote:
September 19th, 2023, 10:20 am
Finally, I'd also welcome any good example [Rule]Investigator patterns.
Maybe add the official RLE for explaining the cell states?
I've pretty much copied that into a table in the Help - but nice idea.

Any good patterns that show off the features?

User avatar
b3s23love
Posts: 97
Joined: May 24th, 2023, 6:30 am
Location: The (Life?) Universe

Re: [Rule]Investigator support in Golly

Post by b3s23love » September 19th, 2023, 1:55 pm

rowett wrote:
September 19th, 2023, 1:46 pm
Any good patterns that show off the features?
I sent a PM to Entity Valkyrie about this. EDIT: They said that they'll prepare some patterns.
Last edited by b3s23love on September 20th, 2023, 4:14 am, edited 1 time in total.

User avatar
muzik
Posts: 5652
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: [Rule]Investigator support in Golly

Post by muzik » September 19th, 2023, 5:15 pm

"aglo" should be changed to "algo". I'll give everything a more thorough read through soon.

Here's a 2-cell glider gun predecessor:

Code: Select all

x = 4, y = 4, rule = B3/S23Investigator
I3$3.C!
Also, in LifeViewer, drawing this exact configuration from a blank board doesn't seem to work all the time - sometimes the cells just flicker in and out of existence when you press play. At other times (seems to happen more often if you use state 8 instead of 9), the state 3 cell disappears at T=1 but reappear afterwards, and in other cases it doesn't reappear afterwards. It's inconsistent and weird. No idea what's going on or if it's just on my end.

Code: Select all

x = 1, y = 1, rule = B3/S23Investigator
b!

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » September 19th, 2023, 5:35 pm

muzik wrote:
September 19th, 2023, 5:15 pm
"aglo" should be changed to "algo". I'll give everything a more thorough read through soon.
Thanks.
muzik wrote:
September 19th, 2023, 5:15 pm
Also, in LifeViewer, drawing this exact configuration from a blank board doesn't seem to work all the time - sometimes the cells just flicker in and out of existence when you press play.
Fixed, thanks.

User avatar
muzik
Posts: 5652
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: [Rule]Investigator support in Golly

Post by muzik » September 21st, 2023, 11:40 am

Here's an example starting paragraph you may wish to adapt:
Investigator mode

[Rule]Investigator rules implement a series of functional states on top of the original two states, which see use in areas such as theoretical circuitry, permitting far more compact solutions in a given target rule than [Rule]Standard would allow.

Investigator rules are a superset of the "Extended Life" rule, devised in 2011 by Martin "Extrementhusiast" Grant, which implemented six new states on top of regular 2-state Life which permitted nonstandard behaviour. One of these cells functions identically to the state-6 cell present in [Rule]History and later [Rule]Super.

An initial version of the rule, titled StateInvestigator, was devised by conwaylife.com forum user "Entity Valkyrie" in April 2018. Unlike what is the case for [Rule]History and [Rule]Super, patterns in Extended Life do not use the same state numbers as are present in [Rule]Investigator and therefore patterns from Extended Life will need manual conversion to function identically in [Rule]Investigator. In addition, odd states are not necessarily "alive" nor are even states "dead" in this rulespace.
This is making me think that a bundled conversion script to convert legacy ExtendedLife patterns (and those in related rules) to [R]Investigator might be a worthwhile thing to include with Golly from now on... anyone want to give it a shot? I can provide what ExtendedLife states should map to each Investigator state, as well as a list of known legacy rules to support.

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: [Rule]Investigator support in Golly

Post by dvgrn » September 21st, 2023, 2:56 pm

muzik wrote:
September 21st, 2023, 11:40 am
This is making me think that a bundled conversion script to convert legacy ExtendedLife patterns (and those in related rules) to [R]Investigator might be a worthwhile thing to include with Golly from now on... anyone want to give it a shot? I can provide what ExtendedLife states should map to each Investigator state, as well as a list of known legacy rules to support.
It's a good idea. My specific suggestion would be to have the script work on clipboard contents. Instead of hitting Ctrl+Shift+O to open a clipboard pattern in a new Golly universe, a shortcut like Alt+O could call the script and pre-process clipboard contents appropriately, replacing rule names and states to build a new Golly 4.3-compatible pattern.

I'd almost suggest that that pre-processing should really become Golly native functionality, but I'm not sure -- quite possibly some people might still want to run native ExtendedLife and other such patterns. (?)

A pre-processor script like that could also end up being something I use a lot (since it would just do normal Ctrl+Shift+O behavior if it doesn't see anything that needs converting.) It could address a separate usability flaw that's been bugging me in Golly for a long time:

When I have a pattern in my clipboard, and I know that the rule string isn't compatible with any rule tables that I have installed, but I want to open it anyway ... well, I can't, directly -- the system currently gives the huge and horrible concatenated error from trying and failing with all possible algos, and then doesn't show me the pattern.

What I want it to do instead is just open the pattern in some default rule that won't break anything, like 256-state B/S012345678 -- so that I can then go to Edit > Set Rule and get the pattern into the rule I want. If this Alt+O conversion script did that, I'd use it all the time instead of Ctrl+Shift+O.

Disaster16439
Posts: 191
Joined: June 30th, 2023, 9:17 am
Location: Suffocating(my coordinates are 3,-64,192929929)

Re: [Rule]Investigator support in Golly

Post by Disaster16439 » October 5th, 2023, 2:59 pm

I was wondering, when will Ipad golly support this? Also, when I update Ipad golly, will my saved patterns get lost?
My 91thn post!
91=7x13
I QUIT CA

User avatar
unname4798
Posts: 466
Joined: July 15th, 2023, 10:27 am

Re: [Rule]Investigator support in Golly

Post by unname4798 » October 7th, 2023, 3:03 am

I want [R]Investigator to be supported in mobile Golly for Android & iOS (together with [R]Super).

User avatar
KittyTac
Posts: 535
Joined: December 21st, 2017, 9:58 am

Re: [Rule]Investigator support in Golly

Post by KittyTac » October 7th, 2023, 6:10 am

Disaster16439 wrote:
October 5th, 2023, 2:59 pm
I was wondering, when will Ipad golly support this? Also, when I update Ipad golly, will my saved patterns get lost?
My 91thn post!
91=7x13
They might be, but you can dig through the local files and copy the folder somewhere else.

User avatar
Entity Valkyrie 2
Posts: 1758
Joined: February 26th, 2019, 7:13 pm
Contact:

Re: [Rule]Investigator support in Golly

Post by Entity Valkyrie 2 » March 2nd, 2024, 6:50 am

rowett wrote:
September 19th, 2023, 10:20 am

Finally, I'd also welcome any good example [Rule]Investigator patterns.
Crossposting my current collection of StateInvestigator patterns (Patterns/StateInvestigator):
StateInvestigator.zip
(310.13 KiB) Downloaded 11 times
Tip: you can right-click on the RLE files in Golly to view the notes on the pattern
Bx222 IS MY WORST ENEMY.

Please click here for my own pages.

My recent rules:
StateInvestigator 3.0
B3-kq4ej5i6ckn7e/S2-i34q6a7
B3-kq4ej5y6c/S2-i34q5e
Move the Box

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » March 3rd, 2024, 11:23 am

dvgrn wrote:
September 21st, 2023, 2:56 pm
When I have a pattern in my clipboard, and I know that the rule string isn't compatible with any rule tables that I have installed, but I want to open it anyway ... well, I can't, directly -- the system currently gives the huge and horrible concatenated error from trying and failing with all possible algos, and then doesn't show me the pattern.

What I want it to do instead is just open the pattern in some default rule that won't break anything, like 256-state B/S012345678 -- so that I can then go to Edit > Set Rule and get the pattern into the rule I want. If this Alt+O conversion script did that, I'd use it all the time instead of Ctrl+Shift+O.
This Golly Lua script will open the contents of the clipboard in rule B/S012345678/256. Feedback welcome!

Code: Select all

-- Safely open a pattern from the clipboard in a benign 256 state rule
-- Author: Chris Rowett, March 2024

local g = golly()
local gp = require "gplus"

local tempname = "safeopenclip.rle"					-- temporary pattern file name
local saferule = "B/S012345678/256"					-- benign 256 state rule
local safeheader = "x = 1, y = 1, rule = "..saferule.."\n"	-- safe rule header

--------------------------------------------------------------------------------

local function safeopen()
	-- get the clipboard text
	local text = g.getclipstr()

	-- check if the clipboard can be loaded
	if not pcall(g.getclip) then
		-- pattern not valid so create a version with the safe rule
		-- remove leading blank lines
		text = text:gsub("^%s+", "")

		-- start position of pattern body
		local startpos = 1

		-- search for an RLE header line (x followed by space or =)
		if text:sub(1,1) == "x" and (text:sub(2,2) == " " or text:sub(2,2) == "=") then
			-- header found so find start of next line
			startpos = text:find("\n") + 1
		end
	
		-- prefix pattern body with the valid header
		text = safeheader..text:sub(startpos)
	end
	
	-- write the contents out to a temporary file
	local filename = g.getdir("temp")..tempname
	file,msg = io.open(filename, "w")
	if file == nil then
		g.note("Could not create temporary file!n\n"..msg)
	else
		file:write(text)
		file:close()

		-- open temporary file containing pattern
		g.open(filename)
	end
end

--------------------------------------------------------------------------------

local status, err = xpcall(safeopen, gp.trace)
if err then g.continue(err) end
-- the following code is always executed

-- ensure the following code *completes*, even if user quits Golly
g.check(false)
EDIT: Simplified the code
EDIT: Updated to attempt to open the clipboard and change to safe rule if this fails

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: [Rule]Investigator support in Golly

Post by dvgrn » March 3rd, 2024, 1:40 pm

rowett wrote:
March 3rd, 2024, 11:23 am
This Golly Lua script will open the contents of the clipboard in rule B/S012345678/256. Feedback welcome!
I like the idea of adding this to Golly's Scripts/Lua folder, with a default Alt+O shortcut.

As usual, the shortcut won't get mapped automatically in an upgrade to the new Golly version -- it will have to be mapped manually, unless someone wants to delete their GollyPrefs so that Golly will regenerate it.

Thoughts?

I think it would be good to adjust the script a bit, though. It can first try to open the clipboard in the normal way (equivalent to Ctrl+Shift+O). If the rule specified in the clipboard pattern is a valid rule, then it's always fine to open the pattern directly in that rule.

B/S012345678/256 is just the rule that a pattern opens with, if the specified rule doesn't work. It's not pretty, but if the alternative is a huge ugly error then it's better to just get the pattern open.

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » March 3rd, 2024, 2:36 pm

dvgrn wrote:
March 3rd, 2024, 1:40 pm
I think it would be good to adjust the script a bit, though. It can first try to open the clipboard in the normal way (equivalent to Ctrl+Shift+O). If the rule specified in the clipboard pattern is a valid rule, then it's always fine to open the pattern directly in
Done, updated version is in the post above.

Note Golly currently opens a small warning dialog if the clipboard can't be opened. Pressing OK will convert the pattern to use the safe rule. Pressing Cancel will abort.
gollywarn.png
gollywarn.png (4.97 KiB) Viewed 657 times
There doesn't appear to be a simple way to ask Golly not to generate the warning dialog. I can take a deeper look if required.

hotdogPi
Posts: 1626
Joined: August 12th, 2020, 8:22 pm

Re: [Rule]Investigator support in Golly

Post by hotdogPi » March 3rd, 2024, 2:40 pm

While we're at it, clicking "Run Clipboard" while there's an RLE in the clipboard tells the user that Perl scripting is no longer supported. It should be able to tell the difference between and RLE and Perl.
User:HotdogPi/My discoveries

Periods discovered: 5-16,⑱,⑳G,㉑G,㉒㉔㉕,㉗-㉛,㉜SG,㉞㉟㊱㊳㊵㊷㊹㊺㊽㊿,54G,55G,56,57G,60,62-66,68,70,73,74S,75,76S,80,84,88,90,96
100,02S,06,08,10,12,14G,16,17G,20,26G,28,38,47,48,54,56,72,74,80,92,96S
217,486,576

S: SKOP
G: gun

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: [Rule]Investigator support in Golly

Post by dvgrn » March 3rd, 2024, 3:00 pm

rowett wrote:
March 3rd, 2024, 2:36 pm
Done, updated version is in the post above.

Note Golly currently opens a small warning dialog if the clipboard can't be opened. Pressing OK will convert the pattern to use the safe rule. Pressing Cancel will abort.

There doesn't appear to be a simple way to ask Golly not to generate the warning dialog. I can take a deeper look if required.
That seems like fairly good behavior, actually. I was just trying to get pcall() working with g.open() instead of g.getclip(), after writing the unmodified clipboard contents to the same temporary file. But it appears that that will just show the full huge ugly error message, which is much worse than the small polite one.

It seems like it might turn out to be a good idea to move this functionality into native Golly code at some point, depending on how much it gets used (it might be just me that is constantly annoyed by this problem). If that happens, then it makes sense to sort out how to avoid that error pop-up.

User avatar
confocaloid
Posts: 3057
Joined: February 8th, 2022, 3:15 pm

Re: [Rule]Investigator support in Golly

Post by confocaloid » March 3rd, 2024, 3:26 pm

I think it would help, even if it just unconditionally opens the pattern in a fixed 256-state rule. (Regardless of whether or not the rulestring is valid.)

If/when this is moved into native code, I think it may be helpful to
  • (a) allow the user to configure the rulestring/name of the "benign" rule. For example it might be set to "//256" by default, but could be changed via preferences to an existing ruletable name. Then that rule is used whenever the pattern could not be opened normally.
  • (b) add a built-in 256-state rule "nothing changes, nothing evolves, can be used for drawing pictures", with predefined state colours. Then that built-in rule can be used by default, instead of a Generations rule.
    (Maybe the state colours can be chosen so that first N colours are visually distinct from each other, for all sufficiently small N?)
Related to (b), see also this 216-state rule:
squareroot12621 wrote:
July 2nd, 2023, 5:59 pm
Is this concept art good?

Code: Select all

x = 640, y = 360, rule = websafe
[...]
squareroot12621 wrote:
July 1st, 2023, 10:06 pm
216-state websafe color rule:

Code: Select all

x = 20, y = 13, rule = websafe
.ABCDE.pLpMpNpOpPpQ.qXrArBrCrDrE$FGHIJK.pRpSpTpUpVpW.rFrGrHrIrJrK$LMN
OPQ.pXqAqBqCqDqE.rLrMrNrOrPrQ$RSTUVW.qFqGqHqIqJqK.rRrSrTrUrVrW$XpApBpC
pDpE.qLqMqNqOqPqQ.rXsAsBsCsDsE$pFpGpHpIpJpK.qRqSqTqUqVqW.sFsGsHsIsJsK
2$sLsMsNsOsPsQ.tXuAuBuCuDuE.vLvMvNvOvPvQ$sRsSsTsUsVsW.uFuGuHuIuJuK.vR
vSvTvUvVvW$sXtAtBtCtDtE.uLuMuNuOuPuQ.vXwAwBwCwDwE$tFtGtHtItJtK.uRuSuT
uUuVuW.wFwGwHwIwJwK$tLtMtNtOtPtQ.uXvAvBvCvDvE.wLwMwNwOwPwQ$tRtStTtUtV
tW.vFvGvHvIvJvK.wRwSwTwUwVwW!
@RULE websafe
@TABLE
n_states:216
neighborhood:Moore
symmetries:none
@COLORS
0 0 0 0
1 0 0 51
2 0 0 102
3 0 0 153
4 0 0 204
5 0 0 255
6 0 51 0
7 0 51 51
8 0 51 102
9 0 51 153
10 0 51 204
11 0 51 255
12 0 102 0
13 0 102 51
14 0 102 102
15 0 102 153
16 0 102 204
17 0 102 255
18 0 153 0
19 0 153 51
20 0 153 102
21 0 153 153
22 0 153 204
23 0 153 255
24 0 204 0
25 0 204 51
26 0 204 102
27 0 204 153
28 0 204 204
29 0 204 255
30 0 255 0
31 0 255 51
32 0 255 102
33 0 255 153
34 0 255 204
35 0 255 255
36 51 0 0
37 51 0 51
38 51 0 102
39 51 0 153
40 51 0 204
41 51 0 255
42 51 51 0
43 51 51 51
44 51 51 102
45 51 51 153
46 51 51 204
47 51 51 255
48 51 102 0
49 51 102 51
50 51 102 102
51 51 102 153
52 51 102 204
53 51 102 255
54 51 153 0
55 51 153 51
56 51 153 102
57 51 153 153
58 51 153 204
59 51 153 255
60 51 204 0
61 51 204 51
62 51 204 102
63 51 204 153
64 51 204 204
65 51 204 255
66 51 255 0
67 51 255 51
68 51 255 102
69 51 255 153
70 51 255 204
71 51 255 255
72 102 0 0
73 102 0 51
74 102 0 102
75 102 0 153
76 102 0 204
77 102 0 255
78 102 51 0
79 102 51 51
80 102 51 102
81 102 51 153
82 102 51 204
83 102 51 255
84 102 102 0
85 102 102 51
86 102 102 102
87 102 102 153
88 102 102 204
89 102 102 255
90 102 153 0
91 102 153 51
92 102 153 102
93 102 153 153
94 102 153 204
95 102 153 255
96 102 204 0
97 102 204 51
98 102 204 102
99 102 204 153
100 102 204 204
101 102 204 255
102 102 255 0
103 102 255 51
104 102 255 102
105 102 255 153
106 102 255 204
107 102 255 255
108 153 0 0
109 153 0 51
110 153 0 102
111 153 0 153
112 153 0 204
113 153 0 255
114 153 51 0
115 153 51 51
116 153 51 102
117 153 51 153
118 153 51 204
119 153 51 255
120 153 102 0
121 153 102 51
122 153 102 102
123 153 102 153
124 153 102 204
125 153 102 255
126 153 153 0
127 153 153 51
128 153 153 102
129 153 153 153
130 153 153 204
131 153 153 255
132 153 204 0
133 153 204 51
134 153 204 102
135 153 204 153
136 153 204 204
137 153 204 255
138 153 255 0
139 153 255 51
140 153 255 102
141 153 255 153
142 153 255 204
143 153 255 255
144 204 0 0
145 204 0 51
146 204 0 102
147 204 0 153
148 204 0 204
149 204 0 255
150 204 51 0
151 204 51 51
152 204 51 102
153 204 51 153
154 204 51 204
155 204 51 255
156 204 102 0
157 204 102 51
158 204 102 102
159 204 102 153
160 204 102 204
161 204 102 255
162 204 153 0
163 204 153 51
164 204 153 102
165 204 153 153
166 204 153 204
167 204 153 255
168 204 204 0
169 204 204 51
170 204 204 102
171 204 204 153
172 204 204 204
173 204 204 255
174 204 255 0
175 204 255 51
176 204 255 102
177 204 255 153
178 204 255 204
179 204 255 255
180 255 0 0
181 255 0 51
182 255 0 102
183 255 0 153
184 255 0 204
185 255 0 255
186 255 51 0
187 255 51 51
188 255 51 102
189 255 51 153
190 255 51 204
191 255 51 255
192 255 102 0
193 255 102 51
194 255 102 102
195 255 102 153
196 255 102 204
197 255 102 255
198 255 153 0
199 255 153 51
200 255 153 102
201 255 153 153
202 255 153 204
203 255 153 255
204 255 204 0
205 255 204 51
206 255 204 102
207 255 204 153
208 255 204 204
209 255 204 255
210 255 255 0
211 255 255 51
212 255 255 102
213 255 255 153
214 255 255 204
215 255 255 255
@NAMES
0 hex 000
1 hex 003
2 hex 006
3 hex 009
4 hex 00c
5 hex 00f
6 hex 030
7 hex 033
8 hex 036
9 hex 039
10 hex 03c
11 hex 03f
12 hex 060
13 hex 063
14 hex 066
15 hex 069
16 hex 06c
17 hex 06f
18 hex 090
19 hex 093
20 hex 096
21 hex 099
22 hex 09c
23 hex 09f
24 hex 0c0
25 hex 0c3
26 hex 0c6
27 hex 0c9
28 hex 0cc
29 hex 0cf
30 hex 0f0
31 hex 0f3
32 hex 0f6
33 hex 0f9
34 hex 0fc
35 hex 0ff
36 hex 300
37 hex 303
38 hex 306
39 hex 309
40 hex 30c
41 hex 30f
42 hex 330
43 hex 333
44 hex 336
45 hex 339
46 hex 33c
47 hex 33f
48 hex 360
49 hex 363
50 hex 366
51 hex 369
52 hex 36c
53 hex 36f
54 hex 390
55 hex 393
56 hex 396
57 hex 399
58 hex 39c
59 hex 39f
60 hex 3c0
61 hex 3c3
62 hex 3c6
63 hex 3c9
64 hex 3cc
65 hex 3cf
66 hex 3f0
67 hex 3f3
68 hex 3f6
69 hex 3f9
70 hex 3fc
71 hex 3ff
72 hex 600
73 hex 603
74 hex 606
75 hex 609
76 hex 60c
77 hex 60f
78 hex 630
79 hex 633
80 hex 636
81 hex 639
82 hex 63c
83 hex 63f
84 hex 660
85 hex 663
86 hex 666
87 hex 669
88 hex 66c
89 hex 66f
90 hex 690
91 hex 693
92 hex 696
93 hex 699
94 hex 69c
95 hex 69f
96 hex 6c0
97 hex 6c3
98 hex 6c6
99 hex 6c9
100 hex 6cc
101 hex 6cf
102 hex 6f0
103 hex 6f3
104 hex 6f6
105 hex 6f9
106 hex 6fc
107 hex 6ff
108 hex 900
109 hex 903
110 hex 906
111 hex 909
112 hex 90c
113 hex 90f
114 hex 930
115 hex 933
116 hex 936
117 hex 939
118 hex 93c
119 hex 93f
120 hex 960
121 hex 963
122 hex 966
123 hex 969
124 hex 96c
125 hex 96f
126 hex 990
127 hex 993
128 hex 996
129 hex 999
130 hex 99c
131 hex 99f
132 hex 9c0
133 hex 9c3
134 hex 9c6
135 hex 9c9
136 hex 9cc
137 hex 9cf
138 hex 9f0
139 hex 9f3
140 hex 9f6
141 hex 9f9
142 hex 9fc
143 hex 9ff
144 hex c00
145 hex c03
146 hex c06
147 hex c09
148 hex c0c
149 hex c0f
150 hex c30
151 hex c33
152 hex c36
153 hex c39
154 hex c3c
155 hex c3f
156 hex c60
157 hex c63
158 hex c66
159 hex c69
160 hex c6c
161 hex c6f
162 hex c90
163 hex c93
164 hex c96
165 hex c99
166 hex c9c
167 hex c9f
168 hex cc0
169 hex cc3
170 hex cc6
171 hex cc9
172 hex ccc
173 hex ccf
174 hex cf0
175 hex cf3
176 hex cf6
177 hex cf9
178 hex cfc
179 hex cff
180 hex f00
181 hex f03
182 hex f06
183 hex f09
184 hex f0c
185 hex f0f
186 hex f30
187 hex f33
188 hex f36
189 hex f39
190 hex f3c
191 hex f3f
192 hex f60
193 hex f63
194 hex f66
195 hex f69
196 hex f6c
197 hex f6f
198 hex f90
199 hex f93
200 hex f96
201 hex f99
202 hex f9c
203 hex f9f
204 hex fc0
205 hex fc3
206 hex fc6
207 hex fc9
208 hex fcc
209 hex fcf
210 hex ff0
211 hex ff3
212 hex ff6
213 hex ff9
214 hex ffc
215 hex fff
127:1 B3/S234c User:Confocal/R (isotropic CA, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: [Rule]Investigator support in Golly

Post by dvgrn » March 3rd, 2024, 3:49 pm

confocaloid wrote:
March 3rd, 2024, 3:26 pm
(b) add a built-in 256-state rule "nothing changes, nothing evolves, can be used for drawing pictures", with predefined state colours. Then that built-in rule can be used by default, instead of a Generations rule.
(Maybe the state colours can be chosen so that first N colours are visually distinct from each other, for all sufficiently small N?)
Yup, good idea -- the boring indistinguishable colors in a 256-state Generations color gradient are sure not very user-friendly -- you have to use the "Pick" tool to figure out what state is what.

I'll be bold here and try to find time to check in a built-in rule that can be used. Since I'd like state N+1 to be reliably distinguishable from state N, all the way through, I don't think squareroot12621's 216 web-safe colors are quite what's wanted. Unless someone has a better list of colors, probably I'll just go with Golly's default palette (i.e., what you get if you switch off the "gradient" application in Preferences.) That's from algos.cpp:

Code: Select all

// These default cell colors were generated by continuously finding the
// color furthest in rgb space from the closest of the already selected
// colors, black, and white.
static unsigned char default_colors[] = {
48,48,48, // better if state 0 is dark gray (was 255,127,0)
0,255,127,127,0,255,148,148,148,128,255,0,255,0,128,
0,128,255,1,159,0,159,0,1,255,254,96,0,1,159,96,255,254,
254,96,255,126,125,21,21,126,125,125,21,126,255,116,116,116,255,116,
116,116,255,228,227,0,28,255,27,255,27,28,0,228,227,227,0,228,
27,28,255,59,59,59,234,195,176,175,196,255,171,194,68,194,68,171,
68,171,194,72,184,71,184,71,72,71,72,184,169,255,188,252,179,63,
63,252,179,179,63,252,80,9,0,0,80,9,9,0,80,255,175,250,
199,134,213,115,100,95,188,163,0,0,188,163,163,0,188,203,73,0,
0,203,73,73,0,203,94,189,0,189,0,94,0,94,189,187,243,119,
55,125,32,125,32,55,32,55,125,255,102,185,102,185,255,120,209,168,
208,166,119,135,96,192,182,255,41,83,153,130,247,88,55,89,247,55,
88,55,247,87,75,0,0,87,75,75,0,87,200,135,59,51,213,127,
255,255,162,255,37,182,37,182,255,228,57,117,142,163,210,57,117,228,
193,255,246,188,107,123,123,194,107,145,59,5,5,145,59,59,5,145,
119,39,198,40,197,23,197,23,40,23,40,197,178,199,158,255,201,121,
134,223,223,39,253,84,149,203,15,203,15,149,15,149,203,152,144,90,
143,75,139,71,97,132,224,65,219,65,219,224,255,255,40,218,223,69,
74,241,0,241,0,74,0,74,241,122,171,51,220,211,227,61,127,87,
90,124,176,36,39,13,165,142,255,255,38,255,38,255,255,83,50,107,
224,142,165,255,181,9,9,255,181,181,9,255,140,238,70,255,74,5,
74,5,255,138,84,51,31,172,101,177,115,17,221,0,0,0,221,0,
0,0,221,220,255,200,0,41,50,255,150,205,178,45,116,113,255,189,
47,0,44,40,119,171,205,107,255,177,115,172,133,73,236,109,0,168,
168,46,207,188,181,203,212,188,35,90,97,52,39,209,184,41,164,152,
227,46,70,46,70,227,211,156,255,98,146,222,136,56,95,102,54,152,
86,142,0,142,0,86,0,86,142,86,223,96,246,135,46,4,208,120,
212,233,158,177,92,214,104,147,88,149,240,147,227,93,148,72,255,133,
209,27,194,147,255,255,44,93,0,160,36,158,182,233,0,96,94,217,
218,103,88,163,154,38,118,114,139,94,0,43,113,164,174,168,188,114,
0,23,119,42,86,93,255,226,202,80,191,155,255,158,136,0,247,62,
234,146,88,0,183,229,110,212,36,0,143,161,105,191,210,133,164,0,
41,30,89,164,0,132,30,89,42,178,222,217,121,22,11,221,107,22,
69,151,255,45,158,3,158,3,45,3,45,158,86,42,29,9,122,22,
213,209,110,53,221,57,159,101,91,93,140,45,247,213,37,185,34,0,
0,185,34,34,0,185,236,0,172,210,180,78,231,107,221,162,49,43,
43,162,49,49,43,162,36,248,213,114,0,214,213,36,248,149,34,243,
185,158,167,144,122,224,34,245,149,255,31,98,31,98,255,152,200,193,
255,80,95,128,123,63,102,62,72,255,62,148,151,226,108,159,99,255,
226,255,126,98,223,136,80,95,255,225,153,15,73,41,211,212,71,41,
83,217,187,180,235,79,0,166,127,251,135,243,229,41,0,41,0,229,
82,255,216,141,174,249,249,215,255,167,31,79,31,79,167,213,102,185,
255,215,83,4,2,40,224,171,220,41,0,4,6,50,90,221,15,113,
15,113,221,33,0,115,108,23,90,182,215,36

Code: Select all

x = 16, y = 16, rule = Display256
.ABCDEFGHIJKLMNO$PQRSTUVWXpApBpCpDpEpFpG$pHpIpJpKpLpMpNpOpPpQpRpSpTpU
pVpW$pXqAqBqCqDqEqFqGqHqIqJqKqLqMqNqO$qPqQqRqSqTqUqVqWqXrArBrCrDrErFrG
$rHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrW$rXsAsBsCsDsEsFsGsHsIsJsKsLsMsNsO$sP
sQsRsSsTsUsVsWsXtAtBtCtDtEtFtG$tHtItJtKtLtMtNtOtPtQtRtStTtUtVtW$tXuAuB
uCuDuEuFuGuHuIuJuKuLuMuNuO$uPuQuRuSuTuUuVuWuXvAvBvCvDvEvFvG$vHvIvJvKvL
vMvNvOvPvQvRvSvTvUvVvW$vXwAwBwCwDwEwFwGwHwIwJwKwLwMwNwO$wPwQwRwSwTwUwV
wWwXxAxBxCxDxExFxG$xHxIxJxKxLxMxNxOxPxQxRxSxTxUxVxW$xXyAyByCyDyEyFyGyH
yIyJyKyLyMyNyO!
#C [[ THUMBNAIL THUMBSIZE 4 ]]
-- Also, we should get back to looking at a script that implements [Rule]Investigator support. This has all been kind of a tangent to that idea, though it does show the possibilities for the kinds of extensions to Golly functionality that can easily happen without any actual native-code changes:
muzik wrote:
September 21st, 2023, 11:40 am
... a bundled conversion script to convert legacy ExtendedLife patterns (and those in related rules) to [R]Investigator might be a worthwhile thing to include with Golly from now on... anyone want to give it a shot? I can provide what ExtendedLife states should map to each Investigator state, as well as a list of known legacy rules to support.
That list hasn't showed up anywhere yet -- right? The conversion script will be much more likely to pop into existence once it's clear exactly what it is supposed to do.

User avatar
muzik
Posts: 5652
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: [Rule]Investigator support in Golly

Post by muzik » March 3rd, 2024, 6:39 pm

dvgrn wrote:
March 3rd, 2024, 3:49 pm
muzik wrote:
September 21st, 2023, 11:40 am
... a bundled conversion script to convert legacy ExtendedLife patterns (and those in related rules) to [R]Investigator might be a worthwhile thing to include with Golly from now on... anyone want to give it a shot? I can provide what ExtendedLife states should map to each Investigator state, as well as a list of known legacy rules to support.
That list hasn't showed up anywhere yet -- right? The conversion script will be much more likely to pop into existence once it's clear exactly what it is supposed to do.
Is the list from this post sufficient?: viewtopic.php?f=3&t=1622&start=3175#p165824

User avatar
dvgrn
Moderator
Posts: 10693
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: [Rule]Investigator support in Golly

Post by dvgrn » March 3rd, 2024, 6:53 pm

muzik wrote:
March 3rd, 2024, 6:39 pm
Is the list from this post sufficient?: viewtopic.php?f=3&t=1622&start=3175#p165824
Looks like it might be. When that post says "[R]Extended", that's the rule family we're going to be calling "[R]Investigator", right?

If I'm understanding right, the theory will be that a pattern in the clipboard with a rule of "ExtendedLife","ExtendedTLife", "ExtendedLife_7", "ExtendedLife_7_mcols", or "extendedlifefancy" will -- if someone uses a conversion script similar to the above Alt+O opening script -- automatically open in Golly in B3S23Investigator, with various states converted over as needed?

We could even build that Investigator conversion functionality into the above "safeopenclip.lua", if nobody could think of a reason to split the functionality into two different scripts. Thoughts on that?

... Obviously if somebody _does_ have ExtendedLife or extendedlifefancy or whatever installed in Golly's Rules folder, there would be no problem opening those patterns directly with File > Open or Ctrl+Shift+O. And in fact, if those rules are installed, a combined-functionality "safeopenclip.lua" script wouldn't do any conversion. It would only attempt the conversion if it ran into an error trying to open a pattern in the normal way.

-- Also, I haven't actually built the new Golly 4.3 beta on my machine yet. Does a pattern in the "StateInvestigator" rule actually get recognized and opened as B3S23Investigator using the Super algo? (I'll try it and find out.) If not, then possibly "StateInvestigator" actually needs to be added to the list of rules that will get converted -- none of the states would need to change, but maybe the rule name would. (?)

Last but not least, do we maybe need to add a "toInvestigator.lua" conversion script to go along with toStandard, toHistory, and toSuper? Shortcut key Alt+I, maybe?

Not sure if it really makes sense to be able to translate from [Rule]Super or [Rule]History to [Rule]Investigator and back again, but I could definitely imagine having a [Rule]Standard pattern and wanting to switch it over to [Rule]Investigator to add a few tricky special-state cells -- or wanting to go from [Rule]Investigator back to plain-vanilla [Rule] to try to figure out how to make the pattern work without the tricky extra cell types.

So probably an update will be needed at least to the toStandard.lua script.

User avatar
Entity Valkyrie 2
Posts: 1758
Joined: February 26th, 2019, 7:13 pm
Contact:

Re: [Rule]Investigator support in Golly

Post by Entity Valkyrie 2 » March 3rd, 2024, 9:37 pm

dvgrn wrote:
March 3rd, 2024, 6:53 pm
muzik wrote:
March 3rd, 2024, 6:39 pm
Is the list from this post sufficient?: viewtopic.php?f=3&t=1622&start=3175#p165824
Looks like it might be. When that post says "[R]Extended", that's the rule family we're going to be calling "[R]Investigator", right?

If I'm understanding right, the theory will be that a pattern in the clipboard with a rule of "ExtendedLife","ExtendedTLife", "ExtendedLife_7", "ExtendedLife_7_mcols", or "extendedlifefancy" will -- if someone uses a conversion script similar to the above Alt+O opening script -- automatically open in Golly in B3S23Investigator, with various states converted over as needed?

We could even build that Investigator conversion functionality into the above "safeopenclip.lua", if nobody could think of a reason to split the functionality into two different scripts. Thoughts on that?

... Obviously if somebody _does_ have ExtendedLife or extendedlifefancy or whatever installed in Golly's Rules folder, there would be no problem opening those patterns directly with File > Open or Ctrl+Shift+O. And in fact, if those rules are installed, a combined-functionality "safeopenclip.lua" script wouldn't do any conversion. It would only attempt the conversion if it ran into an error trying to open a pattern in the normal way.

-- Also, I haven't actually built the new Golly 4.3 beta on my machine yet. Does a pattern in the "StateInvestigator" rule actually get recognized and opened as B3S23Investigator using the Super algo? (I'll try it and find out.) If not, then possibly "StateInvestigator" actually needs to be added to the list of rules that will get converted -- none of the states would need to change, but maybe the rule name would. (?)

Last but not least, do we maybe need to add a "toInvestigator.lua" conversion script to go along with toStandard, toHistory, and toSuper? Shortcut key Alt+I, maybe?

Not sure if it really makes sense to be able to translate from [Rule]Super or [Rule]History to [Rule]Investigator and back again, but I could definitely imagine having a [Rule]Standard pattern and wanting to switch it over to [Rule]Investigator to add a few tricky special-state cells -- or wanting to go from [Rule]Investigator back to plain-vanilla [Rule] to try to figure out how to make the pattern work without the tricky extra cell types.

So probably an update will be needed at least to the toStandard.lua script.
If you have noticed, the folder StateInvestigator/convert-to-stateinvestigator actually contains several scripts that can convert ExtendedLife, extendedlifefancy, lifedeath2, LifeHistory, LifeSuper, staticlifegrey, and Symbiosis patterns into StateInvestigator.
Bx222 IS MY WORST ENEMY.

Please click here for my own pages.

My recent rules:
StateInvestigator 3.0
B3-kq4ej5i6ckn7e/S2-i34q6a7
B3-kq4ej5y6c/S2-i34q5e
Move the Box

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » March 4th, 2024, 4:04 am

dvgrn wrote:
March 3rd, 2024, 6:53 pm
We could even build that Investigator conversion functionality into the above "safeopenclip.lua", if nobody could think of a reason to split the functionality into two different scripts. Thoughts on that?
Perhaps the generic way to do this would to have a list of legacy->new rule conversions defined somewhere:
<legacy rule> <new rule> (<legacy state> <new state>)...

For example:

Code: Select all

ExtendedLife		B3/S23Investigator	2 9	4 14	6 4
ExtendedTLife		B3/S23Investigator	2 9	4 14	6 4
StateInvestigator	B3/S23Investigator
extendedlifefancy	B3/S23Investigator	2 8	4 14	6 4	7 9	8 2
When opening a pattern if the defined rule matches a legacy rule name the rule name is changed to the new rule name and any cell conversions are applied.

If it made sense for this to be part of safeopenclip.lua then this step would be added after failed open of the clipboard and conversion to the benign rule.
dvgrn wrote:
March 3rd, 2024, 6:53 pm
-- Also, I haven't actually built the new Golly 4.3 beta on my machine yet. Does a pattern in the "StateInvestigator" rule actually get recognized and opened as B3S23Investigator using the Super algo?
No it does not since "Investigator" is treated as a postfix in the same way as "History" or "Super".

User avatar
unname4798
Posts: 466
Joined: July 15th, 2023, 10:27 am

Re: [Rule]Investigator support in Golly

Post by unname4798 » March 4th, 2024, 10:06 am

rowett wrote:
March 4th, 2024, 4:04 am
For example:

Code: Select all

ExtendedLife		B3/S23Investigator	2 9	4 14	6 4
ExtendedTLife		B3/S23Investigator	2 9	4 14	6 4
StateInvestigator	B3/S23Investigator
extendedlifefancy	B3/S23Investigator	2 8	4 14	6 4	7 9	8 2
ExtendedTLife's new rule needs to be corrected to B3/S2-i34qInvestigator

User avatar
rowett
Moderator
Posts: 3823
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: [Rule]Investigator support in Golly

Post by rowett » March 5th, 2024, 6:57 am

rowett wrote:
March 4th, 2024, 4:04 am
dvgrn wrote:
March 3rd, 2024, 6:53 pm
We could even build that Investigator conversion functionality into the above "safeopenclip.lua", if nobody could think of a reason to split the functionality into two different scripts. Thoughts on that?
Perhaps the generic way to do this would to have a list of legacy->new rule conversions defined somewhere
I've updated the safeopenclip.lua script so that if it detects a legacy rule it will attempt to convert the pattern to the new rule (along with any required state transformation). The rule mappings are defined near the beginning of the script. If there are others that need adding please let me know.

Code: Select all

-- Safely open a pattern from the clipboard in a benign 256 state rule
-- If the pattern has a known legacy rule then convert it
--
-- Author: Chris Rowett, March 2024
--   some code adapted from toChangeState.lua by Dave Greene

local g = golly()
local gp = require "gplus"

local tempname = "safeopenclip.rle"					-- temporary pattern file name
local saferule = "B/S012345678/256"					-- benign 256 state rule
local safeheader = "x = 1, y = 1, rule = "..saferule.."\n"	-- safe rule header

-- list of legacy rule to new rule mappings with optional list of state conversion pairs
--   [<legacy name>] = {rule = <new name>, map = {<from>, <to>, ...}}
-- note: <legacy name> must be in lower case
local mappings = {
	["extendedlife"] = {rule = "B3/S23Investigator", map = {2, 9, 4, 14, 6, 4}},
	["extendedtlife"] = {rule = "B3/S23-i34qInvestigator", map = {2, 9, 4, 14, 6, 4}},
	["stateinvestigator"] = {rule = "B3/S23Investigator", map = {}},
	["leapinvestigator"] = {rule = "B2n3/S23-qInvestigator", map = {}},
	["eightinvestigator"] = {rule = "B3/S238Investigator", map = {}},
	["pedestrianinvestigator"] = {rule = "B38/S23Investigator", map = {}},
	["merryinvestigator"] = {rule = "B3-eq4ciqt5ky/S2-c3-k4yz5i8Investigator", map = {}}
}

--------------------------------------------------------------------------------

local function swapcells(rect, map)
	-- check if there are cells to change and a mapping
	if #rect > 0 and #map > 0 then
		-- build the map
		local i
		local newstate = {}
		for i = 0, 255 do
			newstate[i] = i
		end

		i = 1
		while i < #map do
			newstate[map[i]] = map[i + 1]
			i = i + 2
		end

		-- get the bounding box
		local minx, miny, sizex, sizey = table.unpack(rect)
		local maxx = minx + sizex - 1
		local maxy = miny + sizey - 1

		-- get the list of non-zero cells
		local cells = g.getcells(rect)
		local numcells = #cells
		local newstate0 = newstate[0]

		-- if state 0 has changed then need to use the gaps in the cell list
		if newstate0 ~= 0 then
			local x = minx
			local y = miny
			local nextx, nexty
			local total = sizex * sizey
			local oldsecs = os.clock()
			local newsecs

			for i = 1, numcells, 3 do
				-- get the next non-zero cell location
				nextx = cells[i]
				nexty = cells[i + 1]

				-- cell states are 0 until the next non-zero cell is reached
				while x < nextx or y < nexty do
					g.setcell(x, y, newstate0)
					x = x + 1
					if x > maxx then
						x = minx
						y = y + 1

						-- might be large pattern so show percentage done each second
						newsecs = os.clock()
						if newsecs - oldsecs >= 1.0 then
							oldsecs = newsecs
							g.show("Changing cell states: "..string.format("%.1f", 100 * ((y - miny) * sizex) / total).."%")
							g.update()
						end
					end
				end
	  
				-- convert the non-zero cell
				g.setcell(nextx, nexty, newstate[cells[i + 2]])
				x = x + 1
				if x > maxx then
					x = minx
					y = y + 1
				end
			end
	
			-- process any final state 0 cells on the last line
			if y <= maxy then
				while x <= maxx do
					g.setcell(x, y, newstate0)
					x = x + 1
				end
			end
		else
			-- no state 0 change so just convert each non-zero cell
			for i = 1, numcells, 3 do
				g.setcell(cells[i], cells[i + 1], newstate[cells[i + 2]])
			end
		end
	end
end

--------------------------------------------------------------------------------

local function getrule(text)
	local rule = ""

	-- search for a rule definition
	local pos = text:find("rule%s*=")
	if pos ~= nil then
		-- if found then find the end of line following it
		local newline = text:find("\n", pos)
		if newline ~= nil then
			-- isolate the rule definition
			rule = text:sub(pos, newline - 1):gsub("rule%s*=%s*", ""):gsub(" *$", "")
		end
	end

	return rule
end

--------------------------------------------------------------------------------

local function safeopen()
	-- get the clipboard text
	local text = g.getclipstr()
	local rule = ""

	-- check if the clipboard can be loaded
	if not pcall(g.getclip) then
		-- pattern not valid so see if the rule is defined
		rule = getrule(text)

		-- remove leading blank lines
		text = text:gsub("^%s+", "")

		-- start position of pattern body
		local startpos = 1

		-- search for an RLE header line (x followed by space or =)
		if text:sub(1, 1) == "x" and (text:sub(2, 2) == " " or text:sub(2, 2) == "=") then
			-- header found so find start of next line
			startpos = text:find("\n") + 1
		end
	
		-- prefix pattern body with the valid header
		text = safeheader..text:sub(startpos)
	end
	
	-- write the contents out to a temporary file
	local filename = g.getdir("temp")..tempname
	file, msg = io.open(filename, "w")
	if file == nil then
		g.note("Could not create temporary file!n\n"..msg)
	else
		file:write(text)
		file:close()

		-- open temporary file containing pattern
		g.open(filename)

		-- if a rule was found then see if it is in the list to convert
		if rule ~= "" then
			local mapping = mappings[rule:lower()]
			if mapping ~= nil then
				-- mapping found so convert states and switch to new rule
				swapcells(g.getrect(), mapping.map)
				g.setrule(mapping.rule)

				-- display the canonical name of the new rule
				g.show("Converted pattern from rule "..rule.." to "..g.getrule()..".")
			end
		end
	end
end

--------------------------------------------------------------------------------

local status, err = xpcall(safeopen, gp.trace)
if err then g.continue(err) end
-- the following code is always executed

-- ensure the following code *completes*, even if user quits Golly
g.check(false)

Post Reply