Share My Creation Game Of Life

Hi,

I wanted to test how Javafx managed a large amount of nodes, and how fast it can run. So I did this adaptation of John Conway's Game Of Life. (https://en.wikipedia.org/wiki/Conway's_Game_of_Life)

With this code, I can handle a grid of 80x80 on my computer. I tried higher than that, but it's too slow. The first attempt I did was to refresh the whole grid every time, but it was way too slow. So I had to store the active square in an array, and search only around those active ones. You can see the debug information, showing the active area.

My conclusion, is either I haven't optimized the code enough, or Javafx just can't handle this project very well.

If anyone has a better idea on how to process the grid faster, please share :)

How to use it?
just click on the grid, it and hit "Play". You can try different shapes : http://www.bitstorm.org/gameoflife/lexicon/

Also:
It's a nice example on how to use a GridPane (wrapper code included).

Capture.PNG
 

Attachments

  • GameOfLife.zip
    5.3 KB · Views: 464

ilan

Expert
Licensed User
Longtime User
hi jmon, i have just published a new b4a app called pixel_studio that i also draw pixels in raws like your example here.

i checked your code and i think it is running to slow because what i have seen is that you are checking in a loop if a cell is filled or not and then fill it
(correct me if i am wrong, i have looked at it only 1 minute) but there is a much faster way to do it.

it runs to slow, try my free source for b4j and tell me what you think (i use the same technology in my app)

(it was meant to be a quiz but @Erel was just to fast to answer it)

https://www.b4x.com/android/forum/threads/quiz.62454/
 

Attachments

  • quiz1.zip
    1.3 KB · Views: 381

jmon

Well-Known Member
Licensed User
Longtime User
it runs to slow, try my free source for b4j and tell me what you think
Awesome, thank you, It seems very simple to implement, I'll try that.

i have seen is that you are checking in a loop if a cell is filled or not and then fill it
Yes, this is how the game of life works, you have to look at how many neighbors are "alive" or "dead" to determine the state of the current cell
 
Top