User:Goldenratio/draft

From LifeWiki
Jump to navigation Jump to search

Planning to split the search program part of glider syntheses tutorial into a separate tutorial, as if we add any more programs it'll get too long. Goldenratio talkcontribs 16:45, 15 May 2021 (UTC)

3-glider collision database

For this part of the tutorial, you will need to use Python scripts with Golly.

synthesise-constellation.py

Below is a 25-glider synthesis of lightweight emulator:

x=163, y = 51, rule = B3/S23 71bo$47bobo19bobo$48b2o20b2o$48bo30bo$79bobo$79b2o18bo$99bobo$63bo6bo 28b2o$49bo12bo5b2o$50b2o10b3o4b2o$49b2o2$92bobo$92b2o$3bobo87bo$3b2o 146b2o2b2o2b2o$4bo70b2o74bo2b4o2bo$bo73b2o75b8o$b2o146b3o8b3o$obo146bo 2bo6bo2bo$150b2o8b2o$93b2o$93bobo$93bo10bo$103b2o$46bobo54bobo$47b2o$ 47bo10bo$56bobo$57b2o$150b2o8b2o$3bobo143bo2bo6bo2bo$3b2o144b3o8b3o$4b o70b2o75b8o$bo73b2o69b2o3bo2b4o2bo$b2o142bobo3b2o2b2o2b2o$obo55bo88bo$ 58b2o$57bobo2$101b2o$81b2o4b3o10b2o$82b2o5bo12bo$51b2o28bo6bo$50bobo$ 52bo18b2o$70bobo$72bo30bo$80b2o20b2o$80bobo19bobo$80bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Notice that in the first step, two blocks are created using a total of four gliders. This may be the most obvious way to synthesise them, but is it the cheapest?

This is where 2718281828's 3G collision database comes in. It contains ~460,000 different three-glider collisions and the objects/constellations they produce, and includes a Python script created by Goldtiger997 to search through the database. Download the three files and place them somewhere convenient, preferably your Scripts\Python folder. In Golly, paste the desired constellation into a new layer and run synthesise-constellation.py. If there are any collisions in the database that produce the same objects in the same positions relative to each other, they will all be displayed.

Let's try this with our two-block constellation. After running the script, we get this:

x=268, y = 36, rule = B3/S23 2bo61bo35bo67bo44bo36bo$obo61bobo34b2o63b2o46b2o35b2o$b2o61b2o34b2o65b 2o44b2o35b2o2$218bo36bo$216b2o35b2o$217b2o35b2o17$111bo39bo$112bo39bo$ 13bo37bo58b3o37b3o$14bo37bo$12b3o35b3o62bo39bo$113b2o38b2o$114b2o38b2o $13b2o36b2o$13bobo35bobo$13bo37bo$201bo64bo$201b2o62b2o$200bobo62bobo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

All six of these collisions work in essentially the same way, by colliding a glider with a pi-heptomino. Since the two blocks are the first step of our lightweight emulator synthesis, we don't have to worry about other nearby objects interfering, so any of these will be suitable. In other cases, you may have to try several of these collisions before finding one that works for the synthesis you're working on.

Now that we have a three-glider collision of the two blocks, our lightweight emulator synthesis has been reduced to 24 gliders, which is currently the cheapest known as of the time of writing:

x=167, y = 47, rule = B3/S23 87bo$66bo21b2o$64bobo20b2o$65b2o26bo$91b2o$92b2o19bo$111b2o$82bo 29b2o$67bo7bobo3bo$68bo6b2o4b3o$66b3o7bo2$105bo58bo$105bobo43b2o2b 2o2b2o3bobo$90b2o13b2o44bo2b4o2bo3b2o$90b2o60b8o$149b3o8b3o$106b2o 41bo2bo6bo2bo$105b2o43b2o8b2o$107bo8b2o$116bobo$116bo$o$b2o3bo$2o 3b2o$5bobo57bo$63bobo$64b2o8bo$75b2o73b2o8b2o$74b2o73bo2bo6bo2bo$ 149b3o8b3o$90b2o60b8o$75b2o13b2o59bo2b4o2bo$74bobo74b2o2b2o2b2o$ 76bo$31b2o$30b2o73bo7b3o$32bo65b3o4b2o6bo$100bo3bobo7bo$68b2o29bo$ 69b2o$68bo19b2o$89b2o$88bo26b2o$93b2o20bobo$92b2o21bo$94bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Note: As of April 2020, a new version of this script is available which contains a subset of four-glider collisions in addition to the two- and three-glider collisions. The installation instructions are the same; just make sure to copy both the 3G and 4G files. If your three-glider search gives no results, try this search instead. The collisions are also laid out in a grid instead of a line in this version.

synthesise-patt.py - synthesising active objects

synthesise-patt.py uses the same database as synthesise-constellation, but is instead used to synthesise unstable objects and is therefore more useful when multiple things are happening during a given synthesis step. It can be found here. Like before, place the three files in your Scripts\Python folder.

Let's start with a 7-glider bridge snake component, taken from Mark Niemiec's database:

x=22, y = 22, rule = B3/S23 5bob2o$5b2obo2$10bo$10bo8bobo$10bo8b2o$20bo2$17b2o$16b2o$18bo5$3o16b2o $2bo16bobo$bo17bo2$3b3o$5bo$4bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

In generation 25, we can see the following unstable object, created from a blinker and two gliders, for 4 gliders total:

x=6, y = 2, rule = B3/S23 3o$3b3o![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Let's see if there's a way to make this object with only 3 gliders, and therefore the bridge snake component in 6 gliders. Place it into a new layer and run the script; if it's running correctly you should see something like "X collisions found, Y collisions tried" in the top left of Golly. After a few seconds, you should see a list of all syntheses whose population counts over time match that of the given object. For this object in particular, you should see these six syntheses:

x=382, y = 14, rule = B3/S23 4bo70bo74bo81bo67bo77bo$5bo70b2o73b2o80bo67b2o73b2o$3b3o69b2o73b2o79b 3o66b2o75b2o$155bo$79bo75b2o147bobo74bo$2o77b2o73bobo76b3o68b2o73b2o$b 2o75bobo154bo69bo74b2o$o158b2o64bobo6bo74b2o65bo$158b2o66b2o80b2o67bo$ 160bo65bo83bo64b3o$7b2o$7bobo67b3o$7bo69bo$78bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Now comes the fun part: determining which, if any, of these is suitable for our bridge snake component. In most cases, collisions where gliders come from only two directions perpendicular to each other tend to be the most likely to work, but in this case I found that the third one from the left seemed promising:

x=10, y = 11, rule = B3/S23 obo$b2o$bo2$4b2o$5b2o$4bo2$8bo$7b2o$7bobo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Mirroring this horizontally, we can see that it seems to fit in well with the snake, as all three gliders come from the other three directions:

x=15, y = 11, rule = B3/S23 12bobo$ob2o8b2o$2obo9bo2$9b2o$8b2o$10bo2$6bo$6b2o$5bobo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 STOP 13 ]]

Now we can paste in the other three gliders, and rewind them a few generations so they show up at the correct time, and our 6G component is complete:

x=17, y = 20, rule = B3/S23 14bobo$2bob2o8b2o$2b2obo9bo2$11b2o$10b2o$12bo2$8bo$8b2o$7bobo3$3o10b2o $2bo10bobo$bo11bo2$3b3o$5bo$4bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

When choosing a generation on which to run the script, it's often a good idea to pause just before the object begins to interact with other stuff, so you get as many potentially useful collisions as possible. However, if you run the script and it gives you several hundred collisions producing irrelevant objects, you may want to consider rewinding a few generations so that the script searches for a more specific population sequence and is therefore more likely to give the pattern you want.

As practice, try to complete this component:

x=16, y = 14, rule = B3/S23 o$b2o$2o2$8bo$9b2o$8bobo$8bobo$9bo2$12b2o$12bo$13b3o$15bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

A four-glider solution can be found here.

find-octohash-Python3.py - finding active objects in 1G collisions

Another database that can be useful when a specific active reaction is needed is the octohash database. The name "octohash" denotes a hash function that returns the exact same hash value for any of the eight orientations of a pattern -- i.e, the octohash of any rotation or reflection of a pattern will always be the same as the octohash of the original pattern. lifelib has a similar function available called "octodigest", but the octohash database is designed to work with Golly and Python, without any dependency on lifelib.

The database is just a series of simple text files containing ten printable ASCII characters for each generation of each glider collision with each constellation. Python can search through these text files very quickly to find matching hashes. The hashing function first finds the canonical orientation of the current phase of the collision. Then it runs the RLE through a SHA1 hash function, throws away everything except the first seven bytes, and encodes the resulting integer in base 90 using the ASCII characters from 37 to 126 -- mostly. Backslashes, apostrophes, and commas are replaced with "!", "#", and "$" respectively, to make the text strings a little less likely to cause any escape-character or quote-character issues, in any programming language that may be used to work with these octohash strings.

This turns out to be a good enough hash function that no hash collisions showed up in the entire set of 12x12 constellation / glider interactions.

The current octohash database catalogues every generation of every possible collision between a single glider and all possible small constellations of common objects. Constellations may contain up to two well-separated objects -- no pseudo still lifes -- and must fit inside a 12x12 bounding box. The objects used in the enumeration were block, boat, beehive, tub, pond, ship, loaf, eater, long boat, and blinker.

To use the octohash database, clone the octohash Git repository, or try the "Download ZIP" option under the "Code" dropdown. In Golly, select the active pattern you want to create with a 1G collision. For example, if you want to create a pentadecathlon by hitting a seed constellation with a trigger glider, place any of the 15 phases of a pentadecathlon in the Golly universe, select it, and run find-octohash-Python3.py.

There turns out to be exactly one constellation of two common objects inside 12x12 that produces a clean pentadecathlon when hit by exactly the right glider:

x=17, y = 8, rule = B3/S23 15bo$14bo$14b3o$2o$obo$2bo5bo$2b2o3bobo$7b2o![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

The original find-octohash.py works with Python 2.x and Golly 3.x. Presumably most users going forward will be using Golly 4.0 or above, so will need to run find-octohash.Python3.py instead.

Unlike synthesise-patt.py vs. synthesise-constellation.py, the octohash search script works equally well for stabilized ash or for active patterns, because the database records a seven-byte hash value for every generation of every collision.

Cleanup

Sometimes the reaction involved in a synthesis produces not only the target product but also some leftovers. For instance, a 20-bit still life appears in the following reaction:

39bo$38bo$38b3o8$31b2o$30bo2bo45bo$22b2o7b2o46bo$21bo2bo54bo$22b2o10bo $33b2o39b2o$33bobo38b2o3$77b2o$76bo2bo$76bo2bo$17b2o47bo2bob2o4b2o$16b o2bo46b5obo$17b2o3b2o$21bo2bo43bob5o$22b2o38b2o4b2obo2bo$61bo2bo$61bo 2bo$62b2o3$5bobo57b2o$6b2o57b2o$6bo10b2o$16bo2bo41bo$8b2o7b2o42bo$7bo 2bo50bo$8b2o8$3o$2bo$bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

To make a synthesis from it, you need to get rid of the surrounding objects with extra gliders. But where should they go? Well, there are a couple of handy programs that can help you out.

glider-destruction.py

For this part of the tutorial, you will need to use Python scripts with Golly.

An easy way to locate the cleanup gliders is to apply gameoflifeboy's glider-destruction.py (see here). Given a pattern, the script attempts to find a clean 1-glider destruction for it; if there isn't one, it tells you the results with minimum bounding box and population. As usual, save the script in Scripts\Python folder.

Since the pattern is rotationally symmetric, considering one half is enough. Select the upper right constellation and copy it to a new pattern:

5bo$5bo$5bo2$2o$2o3$3b2o$2bo2bo$2bo2bo$3b2o![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Run the script and — presto! It gives a solution:

5bo$5bo$5bo2$2o$2o3$3b2o$2bo2bo$2bo2bo$3b2o$8b2o$8bobo$8bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

Pasting it back, we find that it is compatible with the target still life. So the cleanup is done successfully:

23bo$23bo$23bo2$18b2o$18b2o3$21b2o$20bo2bo$20bo2bo$10bo2bob2o4b2o$2bo 7b5obo9b2o$obo23bobo$b2o9bob5o7bo$6b2o4b2obo2bo$5bo2bo$5bo2bo$6b2o3$9b 2o$9b2o2$5bo$5bo$5bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

However, it should be noted that we are lucky in this case. The results from the script is not guaranteed to be actually usable, as either the glider or the cleaning reaction may crash into the target. Besides, the suggested method is not always the most efficient if there isn't a clean 1-glider destruction.

One-glider collision sript

Not written yet. The example non-cleaned up synthesis:

55bo$54bo$54b3o13$45bobo$45b2o$46bo35$5b2o$6b2o$3o2bo4b2o$2bo7bobo2b3o $bo8bo4bo$16bo3$20b2o$20bobo$20bo!2o$9b2o2$5bo$5bo$5bo! [[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

with the example clean up:

55bo$54bo$54b3o13$45bobo$45b2o$46bo35$5b2o$6b2o$3o2bo4b2o$2bo7bobo2b3o $bo8bo4bo$16bo3$20b2o$20bobo$20bo29$24b2o$23b2o$25bo! [[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ZOOM 2 ]]

Seeds of Destruction Game

Also see: Tutorials/Seeds of Destruction Game

For this part of the tutorial, you will need to install Java.

Seeds of Destruction Game is an interactive application that allows one to modify a pattern by hovering the mouse around and see the effects immediately. Basically the idea is simple — put a glider somewhere manually, observe and repeat — but what is italicized makes the trial-and-error process easier.

A brief summary of the procedure, for those who don't bother to read another tutorial:

  1. Copy the pattern to be cleaned to clipboard.
  2. In Seeds of Destruction Game, click the third button from below when its label reads "Puzzle". (If instead it reads "Seed", use mouse wheel to change.) This loads the pattern to the application and creates a new "Puzzle (something)" entry on the right.
  3. Ensure that the first button from above is labelled as "Glider" (if not, use mouse wheel again to change). Adjust the orientation and parity of the glider shown in the second button by rolling mouse wheel.
  4. Click somewhere to lay down the glider and observe how the pattern evolves by rolling mouse wheel on the "Start" and "Gens" buttons. If the result is not satisfying, click the "Puzzle (something)" entry on the right to reset and start a new attempt.
  5. Upon obtaining a good result, click the fifth button from above. This loads the current pattern to clipboard in LifeHistory RLE format (if the label shows "Golly") or in plain two-state RLE format ("Life").

With Seeds of Destruction Game, it is even possible to suppress debris by throwing a glider into the active soup. In the following synthesis for a variant of gray counter, the uppermost glider was found in this way, which tamed quite a lot of mess:

x=114, y = 79, rule = B3/S23 60bobo$61b2o$61bo48$96bo$94bobo$95b2o$101bo$101bobo$101b2o$88bobo$89b 2o$89bo2$91bo$91bobo6bobo$91b2o7b2o$101bo5$27bobo$6bobo18b2o$6b2o20bo$ bo5bo81b2o$2bo86bobo$3o25b2o60b2o$27b2o82b3o$29bo56b2o$3b2o80bo2bo$3bo bo80bobo$3bo83bo![[ THEME 6 GRID THUMBNAIL THUMBSIZE 2 ]]

spark_search

Chris Cain's spark_search (thread) Golly script is a new way to search for replacement gliders to do the same job as hard-to-contruct cells.

Say we want to complete this converter, which transforms Achim's p4 into a "mutated" version:

x=9, y = 17, rule = LifeHistory 3.C$2.2C$2.2C$3.C.C$4.C2$3.A.A$.3A.3A$A3.A3.A$A.A.A.A.A$.2A3.2A2$.2A 3.2A$A.A.A.A.A$A3.A3.A$.3A.3A$3.A.A! [[ GRID THUMBNAIL THUMBSIZE 2 ]]

However, if we run synth_patt on these white cells, we get no solution! But wait, we don't need those exact white cells to trigger this conversion: for example, this similar set works as well:

x=9, y = 19, rule = LifeHistory 2.2C$4.C$.C$2.2C$2.2C$3.C.C$4.C2$3.A.A$.3A.3A$A3.A3.A$A.A.A.A.A$.2A3. 2A2$.2A3.2A$A.A.A.A.A$A3.A3.A$.3A.3A$3.A.A! [[ GRID THUMBNAIL THUMBSIZE 2 ]]

Enumerating all sets of cells which could trigger the conversion and running synth_patt on each one would be an absolute nightmare. This is where spark_search comes in.