Conway's game of life

Show off your games, demos and other (playable) creations.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Conway's game of life

Post 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
Attachments
Game of life.love
(2.88 KiB) Downloaded 700 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Conway's game of life

Post 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.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Conway's game of life

Post by Ranguna259 »

This is actualy realy awesome
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
creeper1919
Prole
Posts: 1
Joined: Sat Aug 10, 2013 6:00 pm

Re: Conway's game of life

Post 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
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Conway's game of life

Post 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.
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Re: Conway's game of life

Post 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.
----------------------------------------
Sluicer Games
jfcaron
Prole
Posts: 6
Joined: Fri Apr 12, 2013 7:12 am

Re: Conway's game of life

Post 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
Attachments
lifeproto12.txt
Rename to *.py and run with python (needs PyGame).
(30.43 KiB) Downloaded 369 times
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Conway's game of life

Post 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.
Attachments
Screenshot_20201029-224242.png
Screenshot_20201029-224242.png (35.8 KiB) Viewed 10873 times
game_of_life_11.3.love
(4.26 KiB) Downloaded 326 times
2020-10-29T18_13_01.png
2020-10-29T18_13_01.png (23.28 KiB) Viewed 10899 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Conway's game of life

Post 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.
Attachments
Screenshot_20201107-215441.png
Screenshot_20201107-215441.png (44.43 KiB) Viewed 10079 times
Screenshot_20201107-215335.png
Screenshot_20201107-215335.png (45.71 KiB) Viewed 10082 times
Color-Game-of-Life_1.01.love
(4.86 KiB) Downloaded 334 times
2020-11-01T19_06_49-Color Game of Life v1.01.png
2020-11-01T19_06_49-Color Game of Life v1.01.png (118.6 KiB) Viewed 10711 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
WhatsTheMusicYo
Prole
Posts: 2
Joined: Wed Nov 18, 2020 4:04 am

Re: Conway's game of life

Post 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'
:( :( :(
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 8 guests