Post Reply 
Conway's game of life with random initial cells
09-10-2023, 04:21 PM
Post: #1
Conway's game of life with random initial cells
Hello All,

I'm new in this forum.
Some time ago I wrote a python script as a kind of screen saver. Starting with a random set of enables cells and let then run the Conway's game of life rules until it comes to cycle the same pattern. Then the programm start again from new set of random celss.

The I decided to rewrite it on HP Prime with the builtin programming language.
The Pgm takes one input parameter for the cell size side in pixel, default is 12, if nothing entered.

It looked cool on the HP Prime, so I just decided to share it with others.

Cheers.


Attached File(s)
.txt  game_of_life_random_init.txt (Size: 1.77 KB / Downloads: 30)
Find all posts by this user
Quote this message in a reply
09-16-2023, 04:25 PM (This post was last modified: 09-16-2023 06:06 PM by komame.)
Post: #2
RE: Conway's game of life with random initial cells
Hi max1138,

Nice job Smile
If you don't mind, I'd like to suggest a few improvements.

1. It would be better to draw in a buffer, and when you finish drawing, immediately display the finished buffer image. This way, there won't be any intermediate effects of drawing individual elements, which can be quite noticeable, especially for smaller cell sizes, e.g., for 5. After such a change, it will look much better, even on slower hardware like G1.
2. It's not worth creating variables just to use them once later in the program. Yes, sometimes it's helpful during debugging, but in algorithms where performance matters, it has a negative impact on program speed. So instead of creating several variables just to substitute them once, it's better to immediately substitute a ready-made expression (this comment mainly concerns the "count" function, which can be eliminated after such a change).
3. It's better to display numerical values in a specific format so that their presentation is independent of the settings in Home => Settings => Number Format. Currently, when someone changes the format to "Fixed," the counters become less readable because decimal places appear. Therefore, it's a good idea to use a conversion instruction to STRING with formatting.
4. For the default cell size (currently 12), there's something wrong with the position of the counters; they are partially cut off at the bottom. I haven't fixed that. However, wouldn't it be better to always show them in the lower corners in the same place regardless of the cell size?

I've attached the version with my minor fixes.

Best regards,
Piotr


Attached File(s)
.txt  game_of_life_random_init_slighty_optimized.txt (Size: 1.97 KB / Downloads: 24)

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)