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 :)
Game of Love
Game of Love
- 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.
-
- Prole
- Posts: 2
- Joined: Sat Sep 19, 2015 9:45 pm
Re: Game of Love
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.
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.
Re: Game of Love
Yeah, I suppose it would be faster if only two tables are used. I'm going to try to implement it that way.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.
Thanks for the help, have a happy New Year too!
Re: Game of Love
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.
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
Who is online
Users browsing this forum: No registered users and 3 guests