Life

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
IMP1
Prole
Posts: 43
Joined: Mon Oct 03, 2011 8:46 pm

Life

Post by IMP1 »

This is my rendition of Conway's Game of Life.
If you don't know anything about it, and don't want to follow the link I provided, it's basically a zero-player game. Which means that after you set the initial conditions, there's not really anything for you to do but sit back and watch what happens.
It's meant to be a kind of celluar automation. There's basically a grid and each square on the grid is either 'alive' or 'dead'. They have certain criteria as when to be born, when to die, and when to survive.

I realise it's not the most fun thing to play, but you can get some weird and cool results.

Image

Controls:
Left click with mouse to create a block, right click to destroy one.
Space to pause
Up/Down to change speed by 0.1
PageUp/PageDown to change speed by 1
Home/End to floor/ceiling speed

Things to add:
  • Looping the grid, maybe having it optional
  • Allowing user to change birth and survival criteria
  • Allowing user to change size of grid and grid squares
  • Pretty colours!
  • Maybe a button for advancing forwards one tick
  • If I'm really ambitious, maybe going backwards... Probably won't happen though
Suggestions for improving at all would be nice :)
Attachments
life.love
(2.13 KiB) Downloaded 232 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Life

Post by Robin »

Nice.

Page up/down change speed really fast, and up and down are quite fast as well. Maybe change them to 10 or 1 "times" per second, rather than 1 or 0.1 "times" per frame?

And going backwards in time is not possible, at least calculating it. If you store each generation, you can go backwards, but that has as disadvantage that it takes up quite a bit of memory.
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Life

Post by kikito »

This is very nicely timed. I'll be doing a game of life in a code retreat next December. I don't think I'll finish it (the point is practicing TDD, not finishing the game)
Robin wrote:And going backwards in time is not possible, at least calculating it. If you store each generation, you can go backwards, but that has as disadvantage that it takes up quite a bit of memory.
Umm you could try compressing the past, I guess. There's lots of repetition in that information. Maybe storing a diff instead of the whole raster or something.
When I write def I mean function.
User avatar
sebast
Prole
Posts: 27
Joined: Tue Nov 08, 2011 2:17 pm

Re: Life

Post by sebast »

In case somebody is interested, I made a simple Conway game of life too.
Computation is done in GPU through the use of Canvas and PixelEffects.
Attachments
life2.love
(1.73 KiB) Downloaded 182 times
Last edited by sebast on Tue Nov 08, 2011 11:07 pm, edited 3 times in total.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Life

Post by miko »

sebast wrote:In case somebody is interested, I made a simple Conway game of life too.
Yeah, everyone makes its own... http://love2d.org/forums/viewtopic.php?f=4&t=2858
sebast wrote:Computation is done in GPU through the use of Canvas and PixelEffects.
Which version of love do I need? Does it depend on opengl implementation/graphic card? Because it does not compile for me :(

Code: Select all

Error: main.lua:64: Cannot compile shader:
0:7(1): error: syntax error, unexpected EXTENSION, expecting $end
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
sebast
Prole
Posts: 27
Joined: Tue Nov 08, 2011 2:17 pm

Re: Life

Post by sebast »

woops, I didn't realize it required some extension...

the "random" code used EXT_gpu_shader4 http://www.opengl.org/registry/specs/EX ... hader4.txt (nvidia > geforce 8)
I removed this part so initialization is even less random (it wasn't at all... anyway)

you still need love 0.8 for Canvas and PixelEffects
Last edited by sebast on Tue Nov 08, 2011 11:07 pm, edited 1 time in total.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Life

Post by TechnoCat »

sebast wrote:In case somebody is interested, I made a simple Conway game of life too.
Computation is done in GPU through the use of Canvas and PixelEffects.
GPGPU, nice.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Life

Post by miko »

sebast wrote:woops, I didn't realize it required some extension...

the "random" code used EXT_gpu_shader4 http://www.opengl.org/registry/specs/EX ... hader4.txt (nvidia > geforce 8)
I removed this part so initialization is even less random (it wasn't at all... anyway)

you still need love 0.8 for Canvas and PixelEffects
Now this is better. I do get a "night sky" view at the first frame, but then the screen gets blanked (black) and nothing changes (except the fps counter).
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
sebast
Prole
Posts: 27
Joined: Tue Nov 08, 2011 2:17 pm

Re: Life

Post by sebast »

Damn, I though it was a good idea to remove all thoses calls to logger to remove extra dependencies... *facepalm*

It seems that the initialization code populates the screen with not enough living cells. It needs a clean random generation code.
I added a fallback mapPixel call for initialization (which is slow), but it still needs a clean and compatible GLSL code

Thank you for this feedback by the way.
Attachments
life2.love
(1.73 KiB) Downloaded 148 times
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Life

Post by miko »

sebast wrote:Damn, I though it was a good idea to remove all thoses calls to logger to remove extra dependencies... *facepalm*

It seems that the initialization code populates the screen with not enough living cells. It needs a clean random generation code.
I added a fallback mapPixel call for initialization (which is slow), but it still needs a clean and compatible GLSL code

Thank you for this feedback by the way.
Works better yet! I get the "night sky" view all the time. But it is static (i.e., nothing changes except fps), so I would call it "death" or "agony" rather than "life"...
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Post Reply

Who is online

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