• Here is a screenshot of a 16x16 version of Conway's Game of Life that I have just got to work with reasonable performance:

    It uses two Uint8Arrays to store the state of the current and next generations. The real performance issue is computing the number of active cells in the 8 surrounding neighbours of a cell. I have used sentinel rows and columns in the arrays to avoid boundary checks and a flattened loop to compute the count. This together with using the Google optimiser in the WebIDE which inlines functions and turns conditional statements into expression etc together with keeping the critical routine in memory and tokenisation gives the sub 1 second generation time. You can try it at https://jeffmer.github.io/JeffsBangleApp­sDev/.
    I will submit it to the official app loader when I have tidied it up.

    I have used a graphics buffer and drawImage to display the cells as I wanted to be able to run widgets and to have the nicely delineated cells.

    An interval timer is used to start a new generation computation every second. As you can see, the computation and display takes on average around 900ms leaving 100ms for widget update etc. This is usually OK, however, I would like to distribute this idle time more evenly during the generation computation to allow more responsive widgets. I could introduce a delay/reschedule call after computing very row, however, I am not sure how to do this - any suggestions?

About

Avatar for jeffmer @jeffmer started