Miscellaneous discussion of CA algorithms and software

For scripts to aid with computation or simulation in cellular automata.
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Miscellaneous discussion of CA algorithms and software

Post by confocaloid »

Following several previous threads, this is a discussion thread for CA-related algorithms and software.

It may be an idea for a script to be run inside Golly, or for an independent utility, or a stand-alone GUI application, or just an algorithm outline, or a "nice-to-have" feature request for an existing application or service that may or may not become an actual feature, etc.
of
To get this started (and to link to previous posts/threads):
  • An utility that automatically generates a human-readable "text with numbers" description of a given pattern. It should work for a sufficiently wide class of patterns -- i.e. not just those objects whose apgcodes start with "x" (e.g. detect and describe a linear growth, a vanishing pattern, a glider synthesis, ..., distinguish between objects and constellations, ...)
  • A simpler way to manually enter symmetric patterns in Golly/LifeViewer. For example, there is an old polyomino-solving application FlatPoly2 by Aad van de Wetering (link to an archived copy of the website; the program is mentioned for example on https://polyominoes.co.uk/); in that program, you can Ctrl+left click on a square (in a rectangular field) and the four symmetric squares are all grayed/ungrayed.
  • A simpler way to know when the Catagolue synthesis for a given object was updated and what was the actual submitted synthesis each time. (I'm aware of Catagolue backups and update logs, and those are helpful, but do not solve the problem entirely -- it's still necessary to look through multiple pages to find the needed information. It would be nice to have a fully automated solution if that's possible.)
  • viewtopic.php?p=162044#p162044 A simple intuitive way to maintain and share collections of patterns, without necessarily having a single central place where the collection is maintained. Probably there would be a dedicated file format "pattern collection" to simplify sharing updates, a way to automatically merge different versions of the same collection into a single collection file (while preserving any updates), and a sufficient set of available operations (list, browse, add, remove, find, export/import (to a stamp collection, to a list of RLEs, ...), ...)
Previous posts/threads:
confocaloid wrote: November 13th, 2023, 10:06 am There were some existing threads for various questions, but as far as I know no single thread for these existed. [...]
Last edited by confocaloid on May 8th, 2025, 2:34 pm, edited 5 times in total.
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
PC101
Posts: 185
Joined: May 9th, 2019, 11:32 pm
Location: :uoᴉʇɐɔo˥

Re: Thread for your CA software/algorithms ideas

Post by PC101 »

-A GUI program that makes caterpillar building easier.
-A program that automatically builds caterpillars.
By caterpillars I mean engineered spaceships that are similar to the spaceships that are self-constructing and self-supporting, like Gemeni, Shieldbug, Camelship, e.t.c.
https://conwaylife.com/wiki/Spaceship#E ... spaceships
Puffer Suppressor
Would we be able to know when we know everything there is to know?
How would we know what we don’t know that we don’t know?

The (34,7)c/156 caterpillar is finished!!! You can download it here.
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your CA software/algorithms ideas

Post by confocaloid »

A fast special-purpose tool to determine periods of high-period "chaotic" oscillators that are either confined to a small bounding box (like the White Whale in LongLife) or live in a small bounded universe (like this p313701632).
confocaloid wrote: November 26th, 2022, 3:16 pm Crossposting from OCA talk:LongLife: the high-period oscillator in LongLife is period-160000346, and the given 75-cell pattern is not a phase of the oscillator but only a predecessor. The population equals 92 at T = 114375463, 274375809, ...

Code: Select all

#C T = 0 (top left), T = 114375463 (top right), T = 12822175 (bottom left),
#C T = 160000346 + 12822175 (bottom right).
#C The two patterns in the bottom row converge after one tick.
x = 49, y = 69, rule = B345/S5
8b2o27b4o2$6b2o2b2o23b3o3b2o2$4b2o6b2o19b2obo6b2o$31bo$2b2o10b2o16bo3b
2o7b2o$2o15bo12b2o15b2o$2bo13bo15bo4bo8bo$2o15b2o11b2o15b2o$2bo13bo15b
5o7b3o$2o15b2o11b2o15b2o$2bo13bo15bo10bo2bo$2o15b2o11b2o15b2o$2bo13bo
15bo11b3o$2o15b2o11b2o15b2o$2bo13bo15bo13bo$2o15b2o11b2o15b2o$2bo13bo
15bo13bo$2o15b2o11b2o15b2o$2bo13bo15bo12b2o$2o15bo12b2o$2bo11b2o16b2o
9b2o$2o29bo$2b2o8b2o19b2o6b2o2$4b2o4b2o23b6o2$6b4o27b2o12$7b4o26b4o2$
5b2o4b2o22b2o4b2o2$3b2o8b2o18b2o8b2o$bo29bo$2b15o15b15o$2o15b2o11b2o15b
2o$2b15o15b15o$2o15b2o11b2o15b2o$2b12ob2o15b12ob2o$2o15b2o11b2o15b2o$
2bobo3b5o3bo15b2o4b5o3bo$2o15b2o11b2o15b2o$2bobo2b7o2bo15bobo2b7o2bo$
2o15b2o11b2o15b2o$2bobo2b10o15bobo2b10o$2o15b2o11b2o15b2o$2b2o4b6o2bo
15b2o4b6o2bo$2o15b2o11b2o15b2o$2b4o7bob2o15b4o7bob2o$2o28b2o$2bo3b9o17b
o3b9o$bo29bo$3b2o6b2o20b2o6b2o2$5b2o2b2o24b2o2b2o2$7b2o28b2o!
Plasmath wrote: October 12th, 2023, 10:25 pm When does this pattern become periodic? It hasn't stabilized for 770,000,000 generations:

Code: Select all

x = 16, y = 16, rule = B2-a3-ai4inrtwyz5-jky6-cn78/S3k4-jqt5-aer6-ac7
bobo5bob2ob2o$ob2o4bo4b2o$obobobo2bob5o$4bob2o3b5o$2b2o2b5o2b3o$4bobo
bo4b2o$o5bo2bobobo$3o4b2obo4bo$bobo5bobo3bo$3b2ob3obo3b2o$2o2b6o2bo$o
2bobo2bo2bob3o$b4o2b2o2bo$b2o2b3obo2bobo$2o4bo4b5o$3obobo3bo4bo!
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.
TYCF
Posts: 542
Joined: August 7th, 2023, 3:44 am
Location: England, United Kingdom,

Re: Thread for your CA software/algorithms ideas

Post by TYCF »

A tool to search through collections of patterns, run each pattern in a rule, and check if they are still a still life / oscillator / spaceship.

Code: Select all

#C I am inactive currently.
x = 5, y = 3, rule = B3/S23
obobo$2ob2o$obobo!

Code: Select all

x = 5, y = 4, rule = B35/S234i8
2bo$bobo$2ob2o$5o!
User avatar
haaaaaands
Posts: 705
Joined: September 7th, 2023, 7:22 am
Location: on the deck of a lwss inside a b3s23 bottle
Contact:

Re: Thread for your CA software/algorithms ideas

Post by haaaaaands »

that already exists: https://catagolue.hatsya.com/home
i know it isn't a program, but it can do it
-- haaaaaands with 6 a's



my hands are typing words!

not quite as active anymore :/
TYCF
Posts: 542
Joined: August 7th, 2023, 3:44 am
Location: England, United Kingdom,

Re: Thread for your CA software/algorithms ideas

Post by TYCF »

haaaaaands wrote: October 27th, 2023, 2:30 pm that already exists: https://catagolue.hatsya.com/home
i know it isn't a program, but it can do it
Yes, but you have identify each pattern.

Code: Select all

#C I am inactive currently.
x = 5, y = 3, rule = B3/S23
obobo$2ob2o$obobo!

Code: Select all

x = 5, y = 4, rule = B35/S234i8
2bo$bobo$2ob2o$5o!
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your CA software/algorithms ideas

Post by confocaloid »

TYCF wrote: October 27th, 2023, 2:29 pm A tool to search through collections of patterns, run each pattern in a rule, and check if they are still a still life / oscillator / spaceship.
You can census each pattern in a collection of RLEs using apgluxe.
https://gitlab.com/apgoucher/apgmera/-/ ... /README.md
Tutorials/Catagolue stdin symmetry

E.g. suppose you have the following six patterns in a file "patterns.txt":

Code: Select all

x = 3, y = 3, rule = B3/S23
b2o$2o$bo!

x = 6, y = 4, rule = B3/S23
bobo$o$bo2bo$3b3o!

x = 6, y = 4, rule = B3/S23
3b3o$2bo2bo$bo$o!

x = 7, y = 3, rule = B3/S23
bo$3bo$2o2b3o!

x = 7, y = 3, rule = B3/S23
bo$3bo$2o2b3o!

x = 6, y = 4, rule = B3/S23
4bo$4b2o$2ob2o$o!
Then it should be possible to census the results of evolving these patterns in an arbitrary CA (b3s23 in this example) roughly as follows:

Code: Select all

git clone https://gitlab.com/apgoucher/apgmera.git
cd apgmera
./recompile.sh --rule b3s23 --symmetry test_stdin
cd ..
./apgmera/apgluxe -t 1 -L 1 -n 1000000000 -i 1 < patterns.txt
If everything is correct then the program will print an output like this at the end:

Code: Select all

----------------------------------------------------------------------
6 soups completed.
143176 tiles processed.
Attempting to contact Catagolue...
Saving results to log.1698439386.k_4BpMMt7rP7qv.txt
Connection was successful.
New seed: k_Tdv9LbcFYSxw; iterations = 1; quitByUser = 1
Terminating...
The log file mentioned in the line "Saving results to..." (in this case "log.1698439386.k_4BpMMt7rP7qv.txt") contains the results, with apgcodes of occurring objects and headerless RLEs of sample soups.

Code: Select all

testing
[...]
@NUM_SOUPS 6
@NUM_OBJECTS 838

@CENSUS TABLE
xp2_7 233
xs4_33 228
xs6_696 161
xq4_153 81
xs5_253 47
xs7_2596 44
xs6_356 18
xs8_6996 9
xs4_252 6
xs6_25a4 4
xs8_69ic 2
xs7_25ac 2
xp2_7e 2
xs14_69bqic 1

@SAMPLE_SOUPIDS
[...]
Last edited by confocaloid on March 1st, 2025, 11:51 pm, edited 1 time in total.
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
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your CA software/algorithms ideas

Post by confocaloid »

Period/displacement detection for moving patterns and partials. The input is a pattern (puffer, rake, partial, etc). The output is a set of "guessed" most likely value(s) of (dx,dy)c/p.
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
silversmith
Posts: 470
Joined: June 15th, 2020, 6:20 pm
Location: Pennsylvania, USA, Earth, Sector 5ff63D6

Re: Thread for your CA software/algorithms ideas

Post by silversmith »

confocaloid wrote: December 24th, 2023, 5:55 pm Period/displacement detection for moving patterns and partials. The input is a pattern (puffer, rake, partial, etc). The output is a set of "guessed" most likely value(s) of (dx,dy)c/p.
My CA program actually has something like this implemented, where you can select an area, then press a button which tells you the period and displacement of the selected pattern. For example, here is a Pi-Heptomino descendant, where you can click "More Options", then "Identify Pattern", and the program will provide some info about such a pattern, up to a period of 300.
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your CA software/algorithms ideas

Post by confocaloid »

This is meant to be two separate patterns running in two non-interacting toroidal universes, but shown on a single sheet. The file format could be structured to allow more than one pattern in a single file (possibly with different rules / topologies, and with associated metadata for each pattern in the file). Actions "Start/stop generating", "Next generation" could be used either for single patterns or for the whole sheet.

Code: Select all

#C patterns from https://conwaylife.com/forums/viewtopic.php?p=176406#p176406
x = 131, y = 78, rule = B3S23History
53.78D$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD
$53.D76BD$53.D76BD$53.D21B2A53BD$53.D7BABA11B2A53BD$53.D8B2A66BD$53.D
8BA67BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$44D9.D76BD$D42BD9.D76BD$D
2BA39BD9.D76BD$D3BA38BD9.D10B2A2B2AB2A57BD$DB3A38BD9.D10B2AB2A3B2A56B
D$D42BD9.D14B2AB2A57BD$D42BD9.D15B3A58BD$D7BA34BD9.D16BA59BD$D8BA33BD
9.D76BD$D6B3A33BD9.D13B2A15BA45BD$D42BD9.D14BA13BABA45BD$D42BD9.D11B
3A15B2A45BD$D12BA29BD9.D11BA64BD$D13BA28BD9.D76BD$D11B3A28BD9.D76BD$D
42BD9.D76BD$D42BD9.D76BD$D17BA24BD9.D76BD$D18BA23BD9.D76BD$D16B3A12BA
10BD9.D76BD$D29B3A10BD9.D76BD$D28BA13BD9.D76BD$D18B3A7B2A12BD9.D76BD$
D17BA3BA20BD9.D76BD$D16BA5BA19BD9.D76BD$D11B2A3BA5BA19BD9.D76BD$D11B
2A3B3AB3A6BA12BD9.D76BD$D30BA11BD9.D76BD$D28B3A11BD9.D48BA27BD$D42BD
9.D49B2A25BD$D15BA26BD9.D48B2A26BD$D14BABA17BA7BD9.D58B2A16BD$D15BA
19BA6BD9.D58B2A6B2A8BD$D33B3A6BD9.D66BA9BD$D42BD9.D59BA4BABA9BD$D42BD
9.D58B3A3B2A10BD$D39BA2BD9.D58BAB2A14BD$D40BABD9.D61B2A13BD$D38B3ABD
9.D58BAB2A14BD$D42BD9.D58B3A15BD$44D9.D59BA16BD$53.D76BD$53.D47B2A27B
D$53.D47B2A27BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.D65BA
10BD$53.D66BA9BD$53.D64B3A9BD$53.D76BD$53.D76BD$53.D76BD$53.D76BD$53.
D76BD$53.D76BD$53.D76BD$53.78D!
#C [[ VIEWONLY ]]
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
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your CA software/algorithms ideas

Post by b-engine »

A Golly Python script to build a self-supporting spaceship based on crawler inputted (via RLE pasted in input box).

For example, if I input the (23,5)c/79 Herschel climber, then it will spit out waterbear or a similar spaceship.
User avatar
dvgrn
Moderator
Posts: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your CA software/algorithms ideas

Post by dvgrn »

b-engine wrote: January 30th, 2024, 5:42 am A Golly Python script to build a self-supporting spaceship based on crawler inputted (via RLE pasted in input box).

For example, if I input the (23,5)c/79 Herschel climber, then it will spit out waterbear or a similar spaceship.
Heh, when someone writes a working Python script that does that, I'm going to be looking through the code very carefully to see where it calls an external AI -- ChatGPT 99.9 or some such. And then I'll finally have to admit that AI has arrived at human-level intelligence.

(Currently ChatGPT is still failing absolutely miserably when faced with even the simplest Conway's Life problems -- it's like trying to get ChatGPT to play chess. Basically it just makes up things that sound plausible, but never comes up with anything that actually works.)

The ability to build a waterbear starting just from its base reaction ... is not currently reducible to a practical algorithm. We could write something that could theoretically brute-force a solution, I suppose, but the sun will burn out before it's done processing.
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your CA software/algorithms ideas

Post by b-engine »

dvgrn wrote: January 30th, 2024, 10:48 am The ability to build a waterbear starting just from its base reaction ... is not currently reducible to a practical algorithm. We could write something that could theoretically brute-force a solution, I suppose, but the sun will burn out before it's done processing.
I think the what the script needs to do is just to add more crawlers and glider (occasionally xWSSes) to support the crawler inputted and themselves.

The input may can been get from the selection of the crawler.
User avatar
silversmith
Posts: 470
Joined: June 15th, 2020, 6:20 pm
Location: Pennsylvania, USA, Earth, Sector 5ff63D6

Re: Thread for your CA software/algorithms ideas

Post by silversmith »

b-engine wrote: February 1st, 2024, 5:15 am I think the what the script needs to do is just to add more crawlers and glider (occasionally xWSSes) to support the crawler inputted and themselves.
Well, you can always try writing a script to do what you want yourself. If it works, you would have your own tool custom built to solve your particular problem.
Haycat2009
Posts: 1050
Joined: April 26th, 2023, 5:47 am
Location: Bahar Junction, Zumaland

Re: Thread for your CA software/algorithms ideas

Post by Haycat2009 »

b-engine wrote: January 30th, 2024, 5:42 am A Golly Python script to build a self-supporting spaceship based on crawler inputted (via RLE pasted in input box).

For example, if I input the (23,5)c/79 Herschel climber, then it will spit out waterbear or a similar spaceship.
Frankly I think that it will most likely be in C++, and if it is true, I will try a Pi-heptomino and see if a 3c/10 spaceship come out. It is going to be insanely difficult, and I will not be surprised if it only works on quantum/biological computers.
~ Haycat Durnak, a hard-working editor
Also, support Conway and Friends story mode!
I mean no harm to those who have tested me. But do not take this for granted.
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your CA software/algorithms ideas

Post by confocaloid »

dvgrn wrote: January 30th, 2024, 10:48 am [...]
The ability to build a waterbear starting just from its base reaction ... is not currently reducible to a practical algorithm. We could write something that could theoretically brute-force a solution, I suppose, but the sun will burn out before it's done processing.
More seriously, that might be reducible to a practical algorithm. It's just that such an algorithm is going to be complicated with multiple steps, generating and testing possibilities, and lots of annoying casework. Look carefully at what it is that humans do to build a waterbear, and write down every step in details, including what could go wrong, what was due to a lucky coincidence vs. what could be bruteforced, etc.

It is not very likely that someone will actually write a working program for that, but in principle I don't think that would require general AI, or "quantum computer", or anything like that. Just an usual computer with enough memory, and lots of domain specific knowledge, sometimes hard to write down exactly, but in principle could be written down so explicitly and unambiguously that a computer could do it, with little further help from a human expert.
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: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your CA software/algorithms ideas

Post by dvgrn »

confocaloid wrote: February 1st, 2024, 10:45 pm
dvgrn wrote: January 30th, 2024, 10:48 am [...]
The ability to build a waterbear starting just from its base reaction ... is not currently reducible to a practical algorithm. We could write something that could theoretically brute-force a solution, I suppose, but the sun will burn out before it's done processing.
More seriously, that might be reducible to a practical algorithm. It's just that such an algorithm is going to be complicated with multiple steps, generating and testing possibilities, and lots of annoying casework...
All totally true. It's only the pure brute-force version that's guaranteed not to ever become workable.

The "build a self-supporting spaceship out of this reaction" script will become not-vaporware as soon as someone comes up with all of those actual specific detailed ideas that can turn it into a practical algorithm.

Until that happens, though, it does seem like a very good example of vaporware.
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your CA software/algorithms ideas

Post by b-engine »

dvgrn wrote: February 1st, 2024, 11:05 pm The "build a self-supporting spaceship out of this reaction" script will become not-vaporware as soon as someone comes up with all of those actual specific detailed ideas that can turn it into a practical algorithm.
Good question. I'd formed an idea of how it works:

1. The script will first find what can the crawler climbs based on the input (either selection or RLE input).
2. The script will try any combination of what can been placed at the front or back of the crawler.
3. The script will try to form a closed glider loop using the crawler.

If anyone have more details, please ask me. Also can someone help me write the Python script?
User avatar
dvgrn
Moderator
Posts: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your CA software/algorithms ideas

Post by dvgrn »

b-engine wrote: February 2nd, 2024, 3:27 am
dvgrn wrote: February 1st, 2024, 11:05 pm The "build a self-supporting spaceship out of this reaction" script will become not-vaporware as soon as someone comes up with all of those actual specific detailed ideas that can turn it into a practical algorithm.
Good question. I'd formed an idea of how it works:

1. The script will first find what can the crawler climbs based on the input (either selection or RLE input).
2. The script will try any combination of what can been placed at the front or back of the crawler.
3. The script will try to form a closed glider loop using the crawler.

If anyone have more details, please ask me. Also can someone help me write the Python script?
I'd like to make some kind of answer to this post rather than just ignoring it, but it's ... kind of difficult to explain how far these three points are from an implementable algorithm. It's hard to see how someone could help you write a Python script that does these things successfully.

Just a script that successfully handles item #1 would be a good accomplishment -- definitely within reach, but quite difficult if you want it to work generally for every possible crawler reaction that someone might put in.

The definition of the word "try" is the vaguest part of items #2 and #3. Each one of those items would need a full page of detailed explanation about how exactly the script would try to do these things.

By analogy...
If the original request was "I want to fly to the moon!", then the above three points are equivalent to

1) Build a rocket
2) Aim the rocket in exactly the right direction
3) Put fuel in the rocket, climb in, and push the "Go" button

As instructions go, these aren't _wrong_ or anything -- but in terms of actually getting to the moon, they lack a lot of really important details.
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your CA software/algorithms ideas

Post by b-engine »

I wrote a pseudocode about the caterpillar making script:

Code: Select all

Note: anything inside (( and )) is either input or variable. 

-

set ((crawler)) to ((selection)) (the pattern selected)
repeat until i = ((10))
      randomly place still life at ((crawler)) ((x,y)) + ((random ((-10,10)),random((-10,10))))
      If ((crawler)) reappears
            set ((crawler_list)) to ((the entire pattern))
            set i to ((i + 1))
randomly arrange ((crawler_list)) until a spaceship appears

However I don't have any idea of how to turn it into Python script.
User avatar
dvgrn
Moderator
Posts: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your CA software/algorithms ideas

Post by dvgrn »

b-engine wrote: February 10th, 2024, 10:24 am I wrote a pseudocode about the caterpillar making script:
...
However I don't have any idea of how to turn it into Python script.
No one else is likely to have any more of an idea than you are, I'm afraid.

In particular, the pseudocode "randomly arrange ((crawler_list)) until a spaceship appears" still contains pretty much the entire unsolved problem.

That one line would probably need to be expanded out to the size of a Ph.D. dissertation (at least) before it could be implemented in Python -- and as others have mentioned, Python is probably too slow to be the right language to use for this project anyway.
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Miscellaneous discussion of CA algorithms and software

Post by confocaloid »

What would be a good, reliable algorithm for automatically computing the number of 'apparent turns' of a "beyblade" object (an oscillator or spaceship)?

The input would be a (reasonably small) pattern.
The output could be one of the following messages:
  • "This is a period-N oscillator that makes K 'apparent turns' per cycle"
  • "This is a period-N (dx,dy)c/dt spaceship that makes K 'apparent turns' per cycle"
  • "This doesn't look like either an oscillator or a spaceship [, as far as can be determined from the first 8192 generations]"
  • "The number of 'apparent turns' is not well-defined for this period-N oscillator"
  • "The number of 'apparent turns' is not well-defined for this period-N (dx,dy)c/dt spaceship"
where N > 1, K > 0, dt > 0, dx, dy must be integer numbers.

The output should at least match the result of counting 'apparent turns' obtained by "a human person sitting and carefully watching how it evolves", for all cases where the latter approach gives an unambiguous answer.
confocaloid wrote: March 8th, 2025, 6:02 pm It looks like these "beyblade" oscillators have another measurable property (in addition to the period): the number of "apparent turns" per cycle. Even though the oscillator takes 884 ticks to repeat, it makes 57 "apparent turns" during one 884-tick cycle. (I counted by running it in Golly and looking.)

However, the concept is going to break (due to loss of continuity) when someone discovers a beyblade oscillator that repeatedly "explodes and reincarnates".
LWSSONHWSSONLWSS wrote: March 7th, 2025, 6:56 pm p884 beyblade

Code: Select all

 x = 35, y = 35, rule = R12,C10,S59-117,200-488,B89-114,155-170,400-488,NC
16.6A$14.11A$13.14A$12.8A2B6A$12.5A7B5A$11.5A10B4A$11.4A12B3A$10.4A5B
8C4A$10.4A4B10C4A$9.5A4B4C5D2C4A$9.6A3B3C8DC3A$9.6A3B3C9D4A$9.7A3B2C3D
3E4D3A$10.7A2B2C2D6E2D2AB$11.7ABC2D8E2D2B$12.7AB2D3E3F3ED2B$2.I11.6AD
2E6F3E2B$.2I11.6ADE8F2E3B$3I11.6AE9F2E3B$3I12.5AF6G3FE2BC$3I12.2IA10G
3FB2C$3I13.2I3H7G3F3C$3I14.2I5H4G3F3C$.I2H13.4I4H3G3F3C$.3H13.4I4H3G2F
3C$.4H13.4I3H3GF4C$2.4H12.4I3H3GF3D$2.4HG11.4I3H3G3D$3.3H2G9.5I2H3G4D
$4.2H3G7.5I3H2G4D$6.4G10I3HGE4D$7.5G6I3H6ED$8.4G6F9E$10.2G7F5E$12.8FE
!
b-engine wrote: February 27th, 2025, 5:59 pm [...] Is there any examples of beyblade spaceships which it explodes and leave ashes that consist of only a reincarnation of itself? [...]
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
dl-rs
Posts: 253
Joined: April 11th, 2022, 12:14 am
Location: I was just a block until a glider crashes with me and I tumbled onto Earth surface in LWSS form.
Contact:

Re: Miscellaneous discussion of CA algorithms and software

Post by dl-rs »

Here are some of my results from a very basic program based on analysing four-glider collisions with gliders from different directions. Currently nothing new have been found. Only a few very common still lives.
I know that some of them won't work due to their awkward positions. However, I hope someone can help speed it up and improve it.
Goals include the ability of finding components, RLE export and customising such parameters.
The code is below, and here are part of the result:

Code: Select all

....................
....................
....................
....................
.....O..............
...O.O..............
....OO..............
....................
....................
....................
....................
....................
......O.....O.......
.....O.....OO.......
.....OOO...O.O......
....................
...OOO..............
.....O..............
....O...............
....................
....................
....................
....................
....................
....................
..........O.........
.........O..........
.........OOO........
....................
....................
......O.............
.......O............
.....OOO............
....................
...........OOO......
...........O........
....OO......O.......
.....OO.............
....O...............
....................
....................
....................
....................
....................
....................
....................
....................
.............O.O....
...O.........OO.....
...OO.........O.....
..O.O...O...........
......O.O...........
.......OO...........
....................
....................
....................
....OOO.............
....O...............
.....O..............
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.......O.....O......
.....O.O....OO......
......OO....O.O.....
....................
....................
....................
..............O.....
..............O.O...
.......OO.....OO....
......O.O...........
........O...........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
................OO..
................O.O.
................O...
..............O.....
.............O......
........O....OOO....
.........OO.........
........OO..........
....................
....................
......OO............
.......OO...........
......O.............
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
......O.............
.....O..............
.....OOO............
....................
...O................
.O.O................
..OO.......OO.......
...........O.O......
...........O........
....................
....OOO.............
......O.............
.....O..............
....................
....................
....................
....................
....................
....................
....................
...............O.O..
....O.O........OO...
.....OO.........O...
.....O..............
....................
..........OO........
.........OO.........
...........O........
....................
........O...........
........OO..........
.......O.O..........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.............O......
............O.......
............OOO.....
....O...............
.....OO.............
....OO..............
..............OOO...
..............O.....
.........OOO...O....
...........O........
..........O.........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.......O............
........OO..........
.......OO...........
....................
..............O.O...
..............OO....
...OOO.........O....
.....O..............
....O.....OO........
..........O.O.......
..........O.........
....................
....................
....................
....................
....................
....................
..........O.........
..........O.O.......
..........OO........
....................
....................
.......O.O..........
........OO..........
........O...........
....................
....................
....................
....................
....................
......OO........O...
.......OO......OO...
......O........O.O..
....................
....................
....................
....................
....................
....................
....................
.............O......
...........OO.......
............OO......
...O................
....OO..............
...OO...............
....................
....................
....................
....................
....................
..........OO........
.........OO.........
...O.......O........
...OO...............
..O.O...............
....................
....................
....................
....................
....................
....................
....................
....................
..................O.
................OO..
.................OO.
.......O.....OO.....
........O...O.O.....
......OOO.....O.....
....................
....................
....................
.............OO.....
.............O.O....
.............O......
....................
....................
....................
....................
....................
....................
....................
....................
....................
.O.O................
..OO................
..O.................
....................
....................
....................
................O...
...............O....
...............OOO..
....................
....................
....................
....................
............OO......
....OOO....OO.......
......O......O......
.....O..............
....................
....................
....................
....................
....................
....................
...............O....
.............OO.....
..............OO....
....................
....................
....O...............
.....O..............
...OOO..............
....................
....................
....................
....................
....................
....................
....................
.....O.........OOO..
.....OO........O....
....O.O.........O...
....................
....................
....................
....................
....................
............O.......
..........OO........
...........OO.......
....................
....................
....................
.....O..............
......OO............
.....OO.............
.............OO.....
.............O.O....
.............O......
....................
....................
....................
..O.................
..OO................
.O.O................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
..........O.........
..........OOO.......
.....O..............
......OO.....OO.....
.....OO......O.O....
.............O......
..OO................
.O.O................
...O................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
............O.O.....
............OO......
.............O......
....................
.......OO...........
......O.O...........
........O...........
...O.O..............
....OO..............
....O...............
......OOO...........
......O.............
.......O............
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.....O.O............
......OO............
......O.............
.............O.O....
.............OO.....
..............O.....
....................
....................
....................
....................
...OO.....OOO.......
....OO....O.........
...O.......O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
.........O.O........
..........OO........
............O.O.....
............OO......
.......OO....O......
........OO..........
.......O............
...............OO...
..............OO....
................O...
....................
....................
....................
....................
....................
....................
....................
...............O....
.............OO.....
..............OO....
....................
....................
....................
....................
....................
....................
.......O.O..........
........OO..........
........O...........
....................
....................
................O...
......OO.......OO...
.....O.O.......O.O..
.......O............
....................
....................
....................
....................
....................
....................
.....O.........O....
......O......OO.....
....OOO.......OO....
....................
....................
....................
....................
....................
....................
....................
...OO...............
..O.O...............
....O...............
....................
.........OO.........
.........O.O........
.........O..........
....................
....................
....................
....................
....................
....................
....................
.............O.O....
.............OO.....
.........O....O.....
..........O.........
........OOO.........
...............OO...
..............OO....
.........OO.....O...
..........OO........
.........O..........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.........O.O........
.........OO.........
..........O.........
.......O............
........O...........
......OOO...........
.OO.................
..OO................
.O..............O...
...............OO...
...............O.O..
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.....O..............
......O.............
....OOO.............
...........O........
..........O.........
..........OOO.......
.....OO.............
....O.O.......O.....
......O......OO.....
.............O.O....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
............O.......
..........OOO..O.O..
...............OO...
.......OO.......O...
......OO............
........O.OOO.......
............O.......
...........O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
..................O.
......O.........OO..
.......O.........OO.
.....OOO............
....................
...............O....
...............OO...
..............O.O...
....................
....................
...........OO.......
..........OO........
............O.......
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.......O............
........O...........
......OOO......O....
..OOO..........O.O..
....O..........OO...
...O................
....................
....................
....................
.......OO...........
......OO............
........O...........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.....O..............
......O.............
....OOO..........OO.
................OO..
..................O.
.......O.O..........
.......OO...........
........O...........
..........OOO.......
............O.......
...........O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
........O.O.........
........OO..........
....O.O..O..........
.....OO.............
.....O..............
....................
....................
....................
....................
....................
..OO................
.O.O................
...O.............O..
................OO..
................O.O.
....................
....................
....................
....................
....................
.......O.O..........
........OO..........
........O...........
....................
...............O....
.............OO.....
..............OO....
....................
....................
....................
....................
....................
..OO................
...OO...............
..O...........OO....
.............OO.....
...............O....
....................
....................
....................
....................
....................
....................
....................
....................
....................
........O...O.O.....
......O.O...OO......
...OO..OO....O......
..O.O...............
....O...............
....................
....................
.............OOO....
.............O......
..............O.....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
............O.......
............O.O.....
......O.....OO......
.......OO...........
......OO............
....................
..........OO........
...........OO.......
..........O.........
.......OO...........
.......O.O..........
.......O............
....................
....................
....................
....................
....................
....................
......O.............
....O.O.............
.....OO.............
....................
....................
......OO............
.....O.O............
.......O...O........
.........OO.........
..........OO........
....................
....................
....................
....................
........OOO.........
........O...........
.........O..........
....................
....................
....................
....................
....................
...............O....
.............OO.....
...O..........OO....
.O.O................
..OO................
....................
....................
....................
....................
....OOO.............
......O.............
.....O..............
..............OO....
..............O.O...
..............O.....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.............O......
...........OO.......
..O.........OO......
...OO...OO..........
..OO...O.O..........
.........O..........
....................
....................
....................
......OOO...........
......O.............
.......O............
....................
....................
....................
....................
....................
....................
....................
....................
........O...........
.......O............
.......OOO..........
....................
....................
....................
...O................
...OO...............
..O.O...............
......O.............
.......OO...........
......OO............
....................
.............OOO....
.............O......
..............O.....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
............O.......
...........O........
...O.......OOO......
....O...............
..OOO...............
....................
....................
........O...........
........OO.......OO.
.......O.O......OO..
..................O.
....................
....................
....................
....................
....................
....................
.......O............
......O.............
......OOO...........
....................
....................
.......O.O..........
........OO..........
........O...........
....................
....................
....................
....................
............O.......
...........OO.......
...........O.O......
.....OO.............
....O.O.............
......O.............
....................
....................
....................
....................
....................
....O...............
.....OO......O......
....OO......O.......
............OOO.....
....................
....................
....................
....................
....................
....................
....................
.....OOO............
.......O............
......O.......O.....
.............OO.....
.............O.O....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.......OO...........
......O.O...........
........O...........
..........O.........
...........O........
.........OOO........
.......OO...........
......OO............
........O...........
..........O.O.......
..........OO........
...........O........
....................
....................
....................
....................
....................
....................
....................
..............O.....
.............O......
.............OOO....
....................
.....O..............
......OO............
.....OO.............
.........OOO........
...........O........
..........O.........
................OOO.
................O...
.................O..
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.............O......
...........OO.......
............OO......
.......OO.....O.....
......O.O......OO...
........O.....OO....
..........OO........
.........OO.........
...........O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........OO.......
............OO......
...........O........
..O.O.........O.O...
...OO.........OO....
...O...........O....
....................
............OOO.....
............O.......
.............O......
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
............O.......
...........O........
...........OOO......
....................
..........O.........
...........O........
.........OOO........
....................
....................
.............O......
.............OO.....
............O.O.....
.........OOO........
.........O..........
..........O.........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.O.........O........
..OO.......O.O......
.OO........OO.......
....................
....O...............
....OO..............
...O.O..............
........OO..........
.......OO...........
.........O..........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
........O....O.O....
......O.O....OO.....
.......OO.....O.....
....................
....................
....................
....................
.......OO...........
......O.O...........
........O...........
..........OO........
.........OO.........
...........O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.........O...O......
.......O.O...O.O....
........OO...OO.....
...........O........
...........OO.......
..........O.O.......
....................
....................
...........OOO......
...........O........
............O.......
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.............O.O....
.....O.......OO.....
...O.O........O.....
....OO..............
....................
....................
....................
....................
....................
...OO...............
....OO........OOO...
...O..........O.....
...............O....
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
..........O.........
..........OOO.......
....................
....................
....................
....................
.....O.O............
......OO............
......O.............
....................
...O.............O..
...OO...........OO..
..O.O...........O.O.
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
.........OO.........
..........OO........
...O................
....OO..............
...OO...............
....................
..............OO....
.............OO.....
...............O....
...OO...............
....OO..............
...O................
....................
....................
....................
....................
....................
....................
...............O....
...............O.O..
...............OO...
.............O......
...........O.O......
............OO......
....................
....................
....................
................O...
...............OO...
...............O.O..
....................
..........OO........
.........O.O........
...........O........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....O.O.............
.....OO.............
.....O..............
............O.......
..........OO....O...
...........OO..OO...
...OO..........O.O..
....OO..............
...O................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...O................
.O.O................
..OO................
.............O......
.............O.O....
.............OO.....
....................
....................
....................
.....OO.............
....O.O.............
......O.............
....................
..........O.........
.........OO.........
.........O.O........
....................
....................
....................
....................
....................
....................
....................
....................
..O.O...............
...OO...............
...O................
....................
....................
.......O............
.......O.O..........
.......OO...........
....................
....................
....................
......OO............
.......OO........O..
......O.........OO..
................O.O.
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
...........O........
...........O.O......
......O.O..OO.......
.......OO...........
.......O............
....................
....................
....................
.......OO...........
......OO............
........O...........
...OO...............
..O.O...............
....O...............
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
................O...
.........O......O.O.
.......O.O......OO..
..O.....OO..........
..OO................
.O.O................
....................
....................
.........OO.........
........OO..........
..........O.........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.................O..
................O...
.....O..........OOO.
......OO............
.....OO......OO.....
.........OO..O.O....
........O.O..O......
..........O.........
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.........O..........
........O...........
........OOO.........
......O.............
......OO............
.....O.O..O.........
...........O........
.........OOO........
....................
....................
...........OOO......
...........O........
............O.......
....................
....................
....................
....................
....................
Attachments
gliders.cpp
(8.36 KiB) Downloaded 24 times
Roaming OCA randomly.

Code: Select all

x = 23, y = 11, rule = B2n3-jknr4ky5-eqry6ik7c8/S234cktwz5ai6-ci7c
2bo2b3o2bo7bo2bo$b2ob5ob2o6b2ob2o$2bo2b3o2bo7bo2bo4$10b2o$b3o5bobo$2o
b2o4b3o$b3o5bobo$10b2o!
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Miscellaneous discussion of CA algorithms and software

Post by confocaloid »

For people interested in four-glider collisions, the links listed in the page may be useful:
https://conwaylife.com/w/index.php?titl ... did=135563
In particular these links:
viewtopic.php?p=157801#p157801 "Re: 4 glider syntheses" (discussion of software)
viewtopic.php?f=9&t=5782 "New 4-glider collision database"
dl-rs wrote: March 27th, 2025, 11:22 am Here are some of my results from a very basic program based on analysing four-glider collisions with gliders from different directions. [...]
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.
wildmyron
Posts: 1571
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: Miscellaneous discussion of CA algorithms and software

Post by wildmyron »

confocaloid wrote: March 22nd, 2025, 7:50 am What would be a good, reliable algorithm for automatically computing the number of 'apparent turns' of a "beyblade" object (an oscillator or spaceship)?
This is a only a partial answer to this question but includes a proof of concept for a proposed method of detecting the number of apparent turns.

The first part of the analysis to determine period and displacement of any beyblade like pattern is I think already pretty well covered by existing tools and I won't cover it here, but will assume the results can be determined for any given pattern.

The general idea to determine number of apparent turns is this:
  • Choose a starting generation to use as reference - can be arbitrary for "well behaved" beyblades. Not sure how to approach beyblades with erratic behaviour because it would be necessary to select a generation which appears to repeat. Maybe: repeat this whole process for multiple reference generations, OR detect a "compact", low population generation and use that.
  • Calculate the peak 2D cross correlation of the reference generation with all generations in one period. The cross correlation window should cover an area large enough to move the window as far as the furthest apparent motion. This can be achieved by doing a full cross correlation, or by tracking movement of the "centre of gravity" of the pattern across one whole period.
  • From the timeseries of peak cross correlation, determine the number of apparent turns by counting peaks. This can by done with an FFT analysis (at least for "well behaved" beyblades (as shown in proof of concept below). For less regular beyblades a robust peak finding algorithm may give a decent result, but it's always hard to know if all the peaks that are "intereting" will be detected, and all the noise rejected. I didn't explore this technique here but there's a lot of good literature (and code) on the topic.
I wrote some code to test this idea with the beyblade posted above. It's in MATLAB because that's what I had to hand but shouldn't be to hard to understand and/or convert to Python (preferably with numpy). Note that MATLAB uses 1-based indexing and matrix indices are by row, then column.

Code: Select all

%% Sample rle pattern conversion

% bb_header0 = 'x = 35, y = 35, rule = R12,C10,S59-117,200-488,B89-114,155-170,400-488,NC';
bb_rle0 = ['16.6A$14.11A$13.14A$12.8A2B6A$12.5A7B5A$11.5A10B4A$11.4A12B3A$10.4A5B', ...
'8C4A$10.4A4B10C4A$9.5A4B4C5D2C4A$9.6A3B3C8DC3A$9.6A3B3C9D4A$9.7A3B2C3D', ...
'3E4D3A$10.7A2B2C2D6E2D2AB$11.7ABC2D8E2D2B$12.7AB2D3E3F3ED2B$2.I11.6AD', ...
'2E6F3E2B$.2I11.6ADE8F2E3B$3I11.6AE9F2E3B$3I12.5AF6G3FE2BC$3I12.2IA10G', ...
'3FB2C$3I13.2I3H7G3F3C$3I14.2I5H4G3F3C$.I2H13.4I4H3G3F3C$.3H13.4I4H3G2F', ...
'3C$.4H13.4I3H3GF4C$2.4H12.4I3H3GF3D$2.4HG11.4I3H3G3D$3.3H2G9.5I2H3G4D', ...
'$4.2H3G7.5I3H2G4D$6.4G10I3HGE4D$7.5G6I3H6ED$8.4G6F9E$10.2G7F5E$12.8FE!'];

rule = 'R12,C10,S59-117,200-488,B89-114,155-170,400-488,NC';
range = 12;
n_states = 10;
sz_x = 35;
sz_y = 35;
beyblade_cells0 = rle_decode(bb_rle0, [sz_x, sz_y]);
period = 884;

pad = range+5; % 5 is arbitrary, allows for movement outside of initial BB
ngrid = 35+pad*2;
cells0 = zeros(ngrid,ngrid);
cells0(pad+(1:sz_x), pad+(1:sz_y)) = beyblade_cells0;

%% Evolve pattern and test cross correlation
% Use original pattern as reference
% Normalise to scale of 1->2 with live cells -> 2 and dead cells -> 1
rescale = @(v)2-mod(v-1, n_states)/(n_states-1);
cells_ref = rescale(beyblade_cells0);

cells2 = cells0;
% Initialise array for results
%   row 1 -> x offset of peak cross correlation
%   row 2 -> y offset of peak cross correlation
%   row 3 -> peak cross correlation
xcorr_res = zeros(3, period);

for ii = 1:period
    cells2 = evolve_ltl(cells2, rule);
    xcorr_pad = 5; % Adjust this according to apparent movement of the core
    xcorr_idxs = 1+pad-xcorr_pad:sz_x+pad+xcorr_pad; % Assumes sx_y == sx_x
    xcorr = conv2(rescale(cells2(xcorr_idxs, xcorr_idxs)), rot90(rot90(cells_ref)), 'valid');
    [m, mi] = max(xcorr, [], 'all');
    [ri, ci] = ind2sub(size(xcorr), mi);
    xcorr_res(:, ii) = [ri-xcorr_pad-1; ci-xcorr_pad-1; m];
end

%% Plot cross correlation results and FFT of peak xcorr values
figure()
tiledlayout(3,1)
nexttile
plot(1:period, xcorr_res(1:2,:))
title('x and y offsets of cross correlation peak')
nexttile
plot(1:period, xcorr_res(3,:))
title('cross correlation peak by generation for one period')
nexttile
Fs = 1; % Sample rate, arbitrarily set to 1 gen/s 
% T = 1/Fs;
L = period;
F = fft(xcorr_res(3,:)); % DFT using fast fourier transform
F(1) = 0; % Set DC component to 0
freq = Fs/L*(0:L-1);
plot(freq, abs(F)) % plot the magnitude of the complex fft spectrum
[peak, f_idx] = max(abs(F));
xlabel('frequency')
title('Amplitude of fft spectrum of the peak cross correlation')
disp([f_idx-1, freq(f_idx), 1./freq(f_idx), period*freq(f_idx)])
rle_decode is a function to convert rle to a matrix of cell states
evolve_ltl is a function to evolve a pattern in this particular LTL rule
The result displayed at the end is: "57.0000 0.0645 15.5088 57.0000".
f_idx works out to be what we want because the sampling rate is treated as 1 per second so it's the length of frequency vector (884) multiplied by the dominant frequency, but the most reliable result is probably obtained from the last value "period*freq(f_idx)"

The output from the plots looks like this:
Note the x and y offsets jump around a bit - there's a dependence on the xcorr_pad value and the scaling parameters used. the jump corresponds to relative shifts in the location of the peak cross correlation when the beyblade is near 180deg rotated from the reference pattern.
Also, ignore the half of the frequency graph > 0.5. That corresponds to the negative frequency side of the dual sided DFT which I didn't bother to wrap around or truncate.
beyblade_analysis.png
beyblade_analysis.png (111.73 KiB) Viewed 5174 times
Edit: Updated FFT analysis code to be a little more rigorous and corresponding update to beyblade analysis image

Edit 2: Correct mixup in FFT frequency interpretation code (off-by-one strikes again)
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.
Post Reply