Program to display 1, 2, n step evolution while editing?

For scripts to aid with computation or simulation in cellular automata.
Post Reply
alextfish
Posts: 2
Joined: August 24th, 2009, 2:39 pm

Program to display 1, 2, n step evolution while editing?

Post by alextfish » August 25th, 2009, 6:30 am

Hiya. There's a feature I've wanted in a Conway's Life editor for decades now, and considered writing my own editor just to have, but it'd probably be simpler to use an existing one if there is one, and I'm sure there must be. Or if not, perhaps it could be written as a Golly script? I have no experience with Golly scripts, but it seems like it ought to be doable, assuming the layer commands are scriptable.

What I want is simply an editing view that lets me toggle pixels, with an automatic display by the side of how the pattern will look 1, 2, and 3 generations later. It seems this'd be quite handy for creating big still lifes, for example, and low-period oscillators, and also for creating patterns that evolve into things like letters.

If Golly scripts can manipulate layers in the way I'd like, then this ought to be fairly simple with a tiled view of 4 layers: have the script hook into every editing click and make it run a few evolutions, replacing the contents of each of the layers with the generated grid at the specified number of generations.

Does anyone know of an editor with this feature, or is anyone feeling kind enough to write a Golly script to do it? I know Python, but haven't used Golly's scripting at all, and while I'd be happy to, I don't fancy grubbing around in documentation for Golly API calls.

Any thoughts gratefully appreciated. Thanks!

User avatar
Andrew
Moderator
Posts: 919
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Program to display 1, 2, n step evolution while editing?

Post by Andrew » August 25th, 2009, 9:45 am

alextfish wrote:... have the script hook into every editing click ...
Unfortunately this is not possible. I've thought about adding a getclick() command to allow mouse interaction, just like getkey() allows keyboard interaction, but I'm putting the finishing touches on version 2.1 at the moment so this idea will have to wait for 2.2. Sorry!
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

alextfish
Posts: 2
Joined: August 24th, 2009, 2:39 pm

Re: Program to display 1, 2, n step evolution while editing?

Post by alextfish » August 25th, 2009, 12:09 pm

Hmm, okay. Thanks for the reply.
Would it be possible to bind a keystroke command to a function to update the layers in the way I describe, then?

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

Re: Program to display 1, 2, n step evolution while editing?

Post by dvgrn » August 25th, 2009, 1:16 pm

alextfish wrote:Hmm, okay. Thanks for the reply.
Would it be possible to bind a keystroke command to a function to update the layers in the way I describe, then?
That's the solution I was thinking of -- yes, it would be easy to set up a script like that.

One way, not necessarily the best way but very simple, might be to set up four layers with known names ("Working", "Plus1", "Plus2", "Plus3") and have the script remove the "Plus" layers if they're there and then immediately re-add them by duplicating the "Working" layer. And run each one for the appropriate number of ticks after adding it, of course, before switching the focus back to the "Working" layer at the end of the script.

Here's a trial implementation. Needs more work, though. It turns out that removing and adding layers like this makes Golly twitchy. The change in number of layers seems to show up on the screen even when the autoupdate option is turned off (as it is by default).

Code: Select all

# Plus3 Life Universe Monitor, version 0.5
import golly as g
oldswitch = g.setoption("switchlayers", False) # don't allow user to switch layers
g.setoption("tilelayers", True)

lyr = 0
while lyr<g.numlayers():
   if len(g.getname(lyr)) == 5 and g.getname(lyr)[:4] == "Plus":
      g.setlayer(lyr)
      g.dellayer()
   else:
      lyr+=1

lyr = 0
plus0lyr=-1
while lyr<g.numlayers():
   if g.getname(lyr) == "Working":
      plus0lyr=lyr
   lyr+=1
if plus0lyr == -1:
   plus0lyr = g.addlayer()

g.setlayer(plus0lyr)
g.setname("Working")

g.duplicate()
g.run(1)
g.setname("Plus1")
g.duplicate()
g.run(1)
g.setname("Plus2")
g.duplicate()
g.run(1)
g.setname("Plus3")

lyr = 0 # find working layer again (in case a layer insertion has shifted it)
plus0lyr=-1
while lyr<g.numlayers():
   if g.getname(lyr) == "Working":
      plus0lyr=lyr
   lyr+=1
g.setlayer(plus0lyr)

g.setoption("switchlayers", oldswitch)
Theoretically you could even run, say, a minimal AutoIt script (if you're running Golly on Windows) that would automatically invoke the update-script key combination every few seconds. Or, to complete the list of ugly workarounds, just balance a small rock on the appropriate key... But no, you'd end up seeing too many error messages, because a lot of the time you'd be trying to draw while the script was running, and Golly would complain.

Anyway, it looks like it will be worth keeping the four layers on the screen all the time; clearing the three "Plus" universes and re-copying cells won't take much time for small patterns, and as long as the autoupdate option is off you shouldn't see anything changing on the screen until the script exits.

Post Reply