Advance n generations

For scripts to aid with computation or simulation in cellular automata.
Post Reply
ivtb
Posts: 11
Joined: January 21st, 2018, 6:07 pm

Advance n generations

Post by ivtb »

I need a script where you type in the number of generations and it runs the current pattern that number of generations, so that we can stay AFK when running time is too big
User avatar
dvgrn
Moderator
Posts: 11981
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Advance n generations

Post by dvgrn »

ivtb wrote: January 22nd, 2020, 6:08 pm I need a script where you type in the number of generations and it runs the current pattern that number of generations, so that we can stay AFK when running time is too big
That's Golly's Scripts/Lua/goto.lua. Or Scripts/Python/goto.py has the same functionality, but you have to install Python for that.

If you need to run a ridiculous number of generations that's easier to write as an expression, use Scripts/Python/goto-expression.py. There isn't a Lua version of that script yet.

Technically these scripts run the pattern to generation T, rather than for T generations, unless you put a plus sign in front of the number. It makes a difference when you're not starting from T=0.

Sometimes Simpler Works Better
The goto scripts do a whole lot of clever switching between step sizes to get to the target generation number as efficiently as possible.

However, sometimes it turns out that that's not what you want. If you want to run 2^24 ticks on a hugely complicated pattern like an 0E0P metacell, for example, the goto scripts will probably attempt a final step of 2^23 or 2^22 or something like that. Golly will attempt to do that, holding all the intermediate hashtiles in memory -- and it will take basically forever.

By contrast, if you run a 0E0P metacell at 2^4 or 2^8, or some reasonable step size in that range, then Golly will be able chug steadily along, and it will get to your target generation eventually without locking up for hours or days. In cases like that, you just need to set a reasonable step size, run a simple script like the one below, and put in the number of steps you want to run:

Code: Select all

import golly as g
steps = g.getstring("Enter number of steps to run: ")
for i in range(int(steps)):
  g.step()
  g.update()
Post Reply