Post subject: Not quite life
Joined: 7/2/2007
Posts: 3960
Today I implemented Conway's Game of Life on a lark. It was something to do. Or anyway, I tried. I screwed something up, so my sim doesn't quite obey the same rules as the traditional Game of Life, which are: * For each step, for each cell, count how many of the 8 neighboring cells are occupied. * If the count is 3, then the cell is occupied. * If the count is 2 and the cell is already occupied, then the cell lives. * Otherwise the cell dies. Whatever I ended up with, it's not this. I can test this easily enough: in the standard sim, a string of 3 occupied cells in a row turns into a repeater, flicking back and forth between horizontal and vertical orientations. Mine doesn't. However, my sim does have two interesting properties, which have prevented me from looking too closely into why it's "not working". First, it seems to be able to run more or less indefinitely without repeating state -- for a 40x30 grid, I ran over 100k steps without getting a repeat once -- which isn't to say that I got a repeat after that many steps; I just canceled the sim there to tweak it. Second, it likes to form what I call "corridors", two parallel lines of occupied cells with a one-cell gap between them. I've posted the code for the sim here. It's written in Python, using Pygame for visualization. The history checking is lines 44-54, the sim step is lines 60-82. I won't claim that this is great code, but it's a simple program so it should still be fairly easy to read.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Post subject: Re: Not quite life
Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Does "newGrid = list(grid)" create a copy, or a reference? Does "a or b and c" evaluate to "(a or b) and c", or "a or (b and c)"? These are two possible sources of errors I thought of when I read the code. [small]I would have posted this in the "Programming for fun" thread instead, but.[/small]
Joined: 7/2/2007
Posts: 3960
Ah ha. "newGrid = list(grid)" creates a new list...but as this is a 2D list, it is a list of references to lists, and those references are not changed. So that explains why the sim doesn't match. Indeed, changing that to "newGrid = [list(s) for s in grid]" gets me proper Conway life. I don't actually know the bindings for boolean comparison; I should have inserted parentheses. My bad. Thanks for looking over the code! And yeah, this should probably have gone into the "programming for fun" thread...
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Banned User
Joined: 6/18/2010
Posts: 183
A year or two ago I saw some impossibly sophisticated Conway's Game of Life simulator in Starcraft: Brood War, of all things. It had something like 800 cells (though Brood War only supports 256 locations on a map), and had a built in interface for both manually toggling cells and changing birth and survival rules. I most likely still have it on a hard drive at my house, once I get back from Christmas vacation I'll see if I can find it.
Skilled player (1417)
Joined: 10/27/2004
Posts: 1978
Location: Making an escape
I thought the rule was that if a live cell had two *or* three neighbors, it stayed alive.
A hundred years from now, they will gaze upon my work and marvel at my skills but never know my name. And that will be good enough for me.
Joined: 7/2/2007
Posts: 3960
If any cell has 3 neighbors, then it becomes a live cell. If a cell that is already alive has 2 or 3 neighbors, then it stays alive, but the 3 neighbors case of that test is subsumed under the spawn-new-cell logic. PointlessBoy: I've also seen a Life sim implemented in LittleBigPlanet. I'm sure one of these days we'll see it in Dwarf Fortress, too.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
When will we see a TAS of Conway's Game of Life?
Joined: 7/2/2007
Posts: 3960
Not before someone makes an actual game out of it, presumably. Despite the name it is merely a simulation / sandbox right now, which doesn't really lend itself to anything beyond playarounds.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Derakon wrote:
Not before someone makes an actual game out of it, presumably. Despite the name it is merely a simulation / sandbox right now, which doesn't really lend itself to anything beyond playarounds.
My attempt at humor was for naught...
Banned User
Joined: 6/18/2010
Posts: 183
Found it! It's a Christmas miracle the laptop this was on still booted ;) http://www.mediafire.com/?493a3zbiu7e09tu Fair warning, this is kiiiinda slooowww. (For example, the default glider gun pattern takes ~10s per generation. Smaller patterns are a bit faster.)
Editor
Joined: 3/10/2010
Posts: 899
Location: Sweden
Someone actually did make a game out of it. From a given intial state, kill every cell with as few toggles as possible. You are allowed to step for as long as you want (including not at all) after each toggle.
Banned User
Joined: 6/18/2010
Posts: 183
henke37 wrote:
Someone actually did make a game out of it. From a given intial state, kill every cell with as few toggles as possible. You are allowed to step for as long as you want (including not at all) after each toggle.
That sounds cool, do you have a link to a page where people give examples or talk about theory or whatever?
Player (203)
Joined: 1/24/2011
Posts: 108
There's an NES game, "The Mutant Virus," which works along these lines. It's a combination of life simulation and shoot-'em-up. It also takes the idea of "computer viruses" far too literally...
Rayas wrote:
Dunno if I'm really clear. I need to drink more.
<br>
adelikat wrote:
The idea was to kill off my family to avoid lost time to them getting sick and other inconvenient things.