Page 1 of 2

Conway's game of life

Posted: Fri Aug 02, 2013 9:44 pm
by veethree
So a good while ago i came across Conway's game of life and decided to try to make it in löve, But failed miserably. The code probably worked in theory, But it was so inefficient it froze löve, I was basically looping through an array like 300 times each frame (hyperbole). But recently i decided to try again, And this time i actually succeeded i think. I'm getting around 40 fps with 2880 cells.

Anyway, If you're not familiar with the game, You can read up on it on the wiki page i linked above because i suck at explaining things.

My implementation has 2880 cells by default, But this can be increased up to 46080 and decreased to 176 with a simple slider, The update rate can also be adjusted.
Controls:
LMB to set cells to "Alive" and RMB to kill them, click and drag possible.
Space toggles the simulation
C clears the grid (kills all cells)
I inverts the grid, (Dead cells become alive and vise versa)
S forces a single world update
and escape closes it.

Default resolution is 1280 x 720, But it has been written to work on most resolutions, meaning the size of the cell grid adjust to the resolution. So if 720p is too big for your monitor, you can change the size in conf.lua and it should still function normally.

Screenshot:
Image

Re: Conway's game of life

Posted: Sat Aug 03, 2013 4:39 am
by raidho36
Neato. Wikipedia also has a schemes for sustaining loops and sustaining spots, along with sustaining moving units, and also for an infinite moving units generator.

Re: Conway's game of life

Posted: Wed Aug 07, 2013 2:44 pm
by Ranguna259
This is actualy realy awesome

Re: Conway's game of life

Posted: Sat Aug 10, 2013 6:08 pm
by creeper1919
whats the point all you have to do to get conways game of life is search it up on google and look at the background
https://www.google.com/search?q=conway% ... =firefox-a

Re: Conway's game of life

Posted: Sat Aug 10, 2013 8:41 pm
by veethree
creeper1919 wrote:whats the point all you have to do to get conways game of life is search it up on google and look at the background
https://www.google.com/search?q=conway% ... =firefox-a
Well my implementation allows you to click and drag which makes drawing shapes a bit easier.

But the point was just practice.

Re: Conway's game of life

Posted: Sun Aug 11, 2013 5:29 pm
by clofresh
The ability to add cells while the simulation is running is actually pretty fun. I could see a possible game mechanic there where you need to coax some cells in equilibrium to move across the board to fight some kind of viral infection or something.

Re: Conway's game of life

Posted: Wed Aug 14, 2013 7:44 pm
by jfcaron
I made an "object-oriented" game of life using PyGame (before finding Löve). It's OO in the sense that instead of using a grid and functions on that grid, each biome is an object that knows about it is position. Instead of updating the grid, each biome counts its neighbors and either dies or creates offspring, stuff like that. It's incredibly inefficient, but it nicely allows you to click to place/kill biomes, you can pause & resume, zoom the "camera", and even a special surprise that you will see if you play the game for a few minutes.

It just needs PyGame and standard Python libraries to run. You need to run it from the terminal. I don't recommend using it as example code because it was my first attempt at learning PyGame and game hobbying in general.

Note: the forum won't let me upload .py files, so just rename the .txt to .py and run it.

Jean-François

Re: Conway's game of life

Posted: Thu Oct 29, 2020 5:30 pm
by darkfrei
Thanks for your example!

Updated to 11.3, added features:
-- added 'r' to random the map
-- map is closed to torus topology
-- resize doesn't delete all dots
-- added GUI to start, clear and random
Issue: I don't know how to save the meta function to the table, but not call it.

Re: Conway's game of life

Posted: Sun Nov 01, 2020 6:11 pm
by darkfrei
Color game of life, for Löve 11.3

Changings:
Added color
Childs become the color of their three parents, random and independently by channel.
Small probability (1%) of mutation for one of three color channels.
"Random" adds new cells, not removes existing.

Re: Conway's game of life

Posted: Fri Nov 20, 2020 12:22 am
by WhatsTheMusicYo
crashed for me with error

Code: Select all

Error

boot.lua:530: conf.lua:2: attempt to index field 'screen' (a nil value)


Traceback

[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
:( :( :(