Golly script for detecting a search pattern?

For scripts to aid with computation or simulation in cellular automata.
Post Reply
MichaelH
Posts: 3
Joined: April 18th, 2010, 9:13 am

Golly script for detecting a search pattern?

Post by MichaelH »

Firstly, I'd like to say a massive thank you to Nathaniel for setting up this awesome website, and also to Andrew and Tomas for their fantastic work on Golly!

I'm looking for a Golly script which would operate as follows:


1. A search pattern is specified (eg. the Blockade).

2. A starting pattern is configured (eg. a methuselah or a random soup).

3. The script steps through the evolution, generation by generation. If the current generation contains one or more copies of the specified search pattern, the script terminates.


The user could then step backwards (using the Undo menu option) and forwards to watch the evolutionary sequence that had created the search pattern.

This could be a very useful script in many situations. For example, if you wanted to know "does a Scorpion appear during the evolution of the Rabbits?", the script could rapidly search through all the generations of the evolution, stopping at generation 4760 when a Scorpion appears. You could then step backwards and forwards to watch the Scorpion being created.

I've been reading about The Online Life-Like CA Soup Search, which sounds similar to the sort of script I'm looking for. I've also had a look through the Golly scripts topic, and the Census script (Python in Golly) topic. But I haven't found a script which does exactly what I'm looking for.

Many thanks in advance for any help you can offer me!
User avatar
Andrew
Moderator
Posts: 1065
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Golly script for detecting a search pattern?

Post by Andrew »

MichaelH wrote:The user could then step backwards (using the Undo menu option) and forwards to watch the evolutionary sequence ...
You couldn't actually do that because all the changes made by a script are accumulated into one big change. This is done for simplicity and efficiency. For example, after running invert.py on a large selection you wouldn't want to have to undo each individual cell change to undo the entire inversion. Ditto for all the individual generation changes made by a script like goto.py.

Anyway, in the scenario you describe I don't think this is a big problem. After the script succeeds you could just run goto.py and enter "-10" to go back 10 gens, then hit 10 spaces to watch the evolution (and then Z/shift-Z or whatever shortcuts you use for undo/redo).
Use Glu or Glui to explore CA rules on non-periodic tilings: DominoLife and HatLife and SpectreLife
MichaelH
Posts: 3
Joined: April 18th, 2010, 9:13 am

Re: Golly script for detecting a search pattern?

Post by MichaelH »

Many thanks for your reply and explanation, Andrew!
Andrew wrote:... all the changes made by a script are accumulated into one big change. This is done for simplicity and efficiency.
Interesting, I didn't know that.
Andrew wrote:... run goto.py and enter "-10" to go back 10 gens ...
I now understand how goto.py goes back to previous generations - from your comments in the source code:

Code: Select all

If the target generation is less than the current generation then we go back to the starting generation (normally 0) and advance to the target.
MichaelH
Posts: 3
Joined: April 18th, 2010, 9:13 am

Re: Golly script for detecting a search pattern?

Post by MichaelH »

I've now written a little Java program which operates as follows:

1. A GIF image is specified, containing a pattern in which to search (eg. a random soup, or a generation in the evolution of a methuselah). Such an image can be generated by Golly using the giffer.pl script.

2. One or more GIF images are specified, containing patterns to search for (eg. a still life, a phase of an oscillator or spaceship, etc).

3. The Java program finds every occurrence of the search patterns in the input pattern, and reports their coordinates.

It's fairly fast - it can search a 25 megapixel random soup in about 2 seconds. I'd be happy to share the source code with anyone who's interested.

I'd still be interested to hear from anyone who knows of (or can write) a Golly script to perform the same task, especially a script that can step through an evolution and search each generation. I would write such a script myself, but sadly I don't yet know how to program in Perl or Python :-)
Post Reply