Game of Love

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
joqmos
Prole
Posts: 6
Joined: Mon Jan 02, 2017 3:29 am

Game of Love

Post by joqmos »

Hi!

I've been working on an implementation of Conway's Game of Life with rjcobourn over the past few days. You can find the source code here and the latest release here.

Any feedback is appreciated :)
Attachments
game-of-love.love
Latest version
(377.78 KiB) Downloaded 251 times
Last edited by joqmos on Tue Jan 03, 2017 4:33 pm, edited 2 times in total.
MasterGeek
Prole
Posts: 2
Joined: Sat Sep 19, 2015 9:45 pm

Re: Game of Love

Post by MasterGeek »

The way you update the grid to the next state is allocating tables all over the place, even when LuaJIT does a great job optimizing the code is not good to have table allocation inside tight or recurrent loops. I mean specifically this line:

https://github.com/joqmos/game-of-love/ ... te.lua#L53

You could instead have two tables, one being the actual state and the other being the next one and you could keep alternating them so you generate one based on the other and viceversa.

Happy New Year btw.
User avatar
joqmos
Prole
Posts: 6
Joined: Mon Jan 02, 2017 3:29 am

Re: Game of Love

Post by joqmos »

MasterGeek wrote:The way you update the grid to the next state is allocating tables all over the place, even when LuaJIT does a great job optimizing the code is not good to have table allocation inside tight or recurrent loops. I mean specifically this line:

https://github.com/joqmos/game-of-love/ ... te.lua#L53

You could instead have two tables, one being the actual state and the other being the next one and you could keep alternating them so you generate one based on the other and viceversa.

Happy New Year btw.
Yeah, I suppose it would be faster if only two tables are used. I'm going to try to implement it that way.

Thanks for the help, have a happy New Year too!
User avatar
joqmos
Prole
Posts: 6
Joined: Mon Jan 02, 2017 3:29 am

Re: Game of Love

Post by joqmos »

I've released version 0.2, you can find it here.
The algorithm has been optimized, and you can now adjust the speed of the game.
Attachments
game-of-love.love
Version 0.2
(377.78 KiB) Downloaded 191 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest