John Conway's Game of Life
|
10-26-2020, 03:02 PM
(This post was last modified: 11-06-2020 03:30 PM by btabone.)
Post: #1
|
|||
|
|||
John Conway's Game of Life
One more implementation of John Conway's Game of Life on HP Prime. I like this particular problem as a tool for learning new platforms. This was a chance to get comfortable with matrix operations and references as well as play around with rendering on the screen and learn HP Prime programming in general. The source is in github here:
https://github.com/hybridmachine/hpprime...GameOfLife I have attached the most recent version on this thread as well. Right now (as of 10/26/2020) there are three pre-canned starting patterns and the app only renders the first 50 generations but it is a start. When launched: 1) First the user is prompted for a grid size (m x m). 50 is a reasonable place to start. 2) The user is prompted to pick a starting pattern Once done, the rendering progresses until generation 50. I do plan to add: 1) initial pattern loading from a user defined matrix 2) generation count display. -> Added 11/6/2020 3) auto vs stepped rendering (where the user can choose to pause and single step). |
|||
10-27-2020, 03:41 PM
Post: #2
|
|||
|
|||
RE: John Conway's Game of Life
I tried your program in the emulator, there it runs without any problem. My HW1 and my HW2 error out with insufficient memory in the line you DIMGROB(...).
Arno |
|||
10-27-2020, 04:24 PM
Post: #3
|
|||
|
|||
RE: John Conway's Game of Life
On the Android, I get a syntax error at SLIST on line 82 (with the default Function app).
(Or earlier, with Geometry app as my default). Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-27-2020, 10:11 PM
Post: #4
|
|||
|
|||
RE: John Conway's Game of Life
(10-27-2020 03:41 PM)Arno K Wrote: I tried your program in the emulator, there it runs without any problem. My HW1 and my HW2 error out with insufficient memory in the line you DIMGROB(...). What size grid are you specifying? I'll try it out on my end. I test in the PC simulator and on my gen 2 HP prime. I usually run a 50x50 grid. |
|||
10-27-2020, 10:21 PM
Post: #5
|
|||
|
|||
RE: John Conway's Game of Life | |||
10-27-2020, 10:31 PM
Post: #6
|
|||
|
|||
RE: John Conway's Game of Life
I guess SLIST() stands for ΣLIST()
On the iOS app I get no result: blank screen and nothing moves, then the app crashes (not the program, the iOS app). Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co |
|||
10-28-2020, 02:11 AM
Post: #7
|
|||
|
|||
RE: John Conway's Game of Life
(10-27-2020 10:31 PM)pinkman Wrote: I guess SLIST() stands for ΣLIST() What size grid to you specify (I start with 50, that works on my gen 2 HP Prime). I think I need to switch from matrices to arrays of bits for the internal data structure. Optimization time |
|||
10-28-2020, 06:50 AM
Post: #8
|
|||
|
|||
RE: John Conway's Game of Life
(10-27-2020 10:11 PM)btabone Wrote:(10-27-2020 03:41 PM)Arno K Wrote: I tried your program in the emulator, there it runs without any problem. My HW1 and my HW2 error out with insufficient memory in the line you DIMGROB(...). Well, when I start it from the program-catalogue I am prompted to input a number, the same as entering in the input line, I tried diverse (2,3,50,100) on my HW2 always that error. Arno |
|||
10-28-2020, 07:08 PM
Post: #9
|
|||
|
|||
RE: John Conway's Game of Life
(10-28-2020 06:50 AM)Arno K Wrote:(10-27-2020 10:11 PM)btabone Wrote: What size grid are you specifying? I'll try it out on my end. I test in the PC simulator and on my gen 2 HP prime. I usually run a 50x50 grid. Are you running the code from https://github.com/hybridmachine/hpprime...eOfLife.hp ? I have a commented out SUBGROB line but no DIMGROB . It should prompt you for two things. The first is the size of the play board (50 works well for me) the second is the starting pattern. In any event, I am working on some memory optimizations, I think passing around the board matrix like that is eating up stack memory for the functions, I'm going to experiment with making it a program global then longer term I'll look at using bit masks instead of complete integers for the on/off state info held in that matrix. |
|||
10-29-2020, 02:41 PM
Post: #10
|
|||
|
|||
RE: John Conway's Game of Life
I took the version to be downloaded here, it only prompts for one input, as I didn't know what to enter I tried 0, 1, 2 and later 50, 1 and 2 worked fine in the emulator. Perhaps you should write a self-explaining input part for your program.
Arno |
|||
10-30-2020, 02:28 AM
Post: #11
|
|||
|
|||
RE: John Conway's Game of Life
(10-29-2020 02:41 PM)Arno K Wrote: I took the version to be downloaded here, it only prompts for one input, as I didn't know what to enter I tried 0, 1, 2 and later 50, 1 and 2 worked fine in the emulator. Perhaps you should write a self-explaining input part for your program. I found a bug where I wasn't properly setting up G1 (where I do the render then copy to G0). I fixed that (had to actually DIMGROB(G1...) and also moved the CurrentGen and NextGen matrices to app global variables to reduce memory load from passing by value. There are more optimizations to do but I think this should get over the first set of issues. I also default to a size 50 square grid (works for me on my PC simulator and my G2 Prime). Code is updated both here and on github |
|||
10-30-2020, 04:31 PM
Post: #12
|
|||
|
|||
RE: John Conway's Game of Life
Ok, now it works on my HW2 and the emulator, the line asking for the grid-size is not properly displayed and the programs name should end with".hpprgm", otherwise it can't be opened by the Connectivity Kit, although it is shown in the Content-Window. I had to open it with notepad+ and copy the contents into a newly made program in the ConnKit.
Arno |
|||
11-02-2020, 10:58 PM
Post: #13
|
|||
|
|||
RE: John Conway's Game of Life
(10-30-2020 04:31 PM)Arno K Wrote: Ok, now it works on my HW2 and the emulator, the line asking for the grid-size is not properly displayed and the programs name should end with".hpprgm", otherwise it can't be opened by the Connectivity Kit, although it is shown in the Content-Window. I had to open it with notepad+ and copy the contents into a newly made program in the ConnKit. Arno, Good info on the .hpprgm, I'll rename it in github and here. Thanks for all of the feedback. My next adventure is to convert to using a list of integers for bit masking instead of a full matrix, since that will be much more space efficient than the current full matrix approach. I'll fix the label for the starting grid size as well. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)