![]() Scratch is still single-threaded AFAIK, and the engine decides when to repaint - it happens at certain safe points, after global loop iterations, wait blocks, etc. (3) That's a real interesting one - I would love to do async or parallel painting / generation, but I am not aware how this can be achieved within Scratch code. So I switched back to redrawing the whole grid each time. Also on many grids, the number of updated 2x2 groups and the number of 2x2 groups containing active cells are not that far apart. Why? Because as TheLogFather has noted, housekeeping plus checking state change plus changing pen color might cost more than what you save on painting. ![]() (2) I actually tried to draw changed cells only (I even had all data required already, well for 2x2 cell groups that is), and it turned out to be slower for most grids. Here are my takes: (1) Pen down/up was also the quickest way I came up with. Asynchronous is better than frameskipping.For Scratch it's definitely the other way around – it can draw the cells quicker than calculating the next generation. Gtoal wrote:3) if possible decouple the cycle of generation from the display rate, assuming you can create generations faster than the frame rate (eg you can create 100 generations per second but only display 25 screen updates per second). I dunno for sure, but I wouldn't be surprised if there's not much in it. The question is whether reading a list item 120x90x2 times (for the comparisons), and then the extra block interpretation for the 120x90 comparisons, is quicker than ~1/10th that many pen-downs. But only redrawing those that change requires testing each and every cell against the same cell of the previous generation (and then still doing the same test it currently does to see whether the changed cell should be ‘on’ or ‘off’, but only for changed cells). Most of the cells are blank, so you draw nothing (if you've started from a cleared pen canvas). Gtoal wrote:2) just draw cells that change It's not entirely clear that will be quicker. Gtoal wrote:last time I looked at this problem, I learned: 1) use pen down/pen up to draw cells, it's much faster than stamping Absolutely! (Already doing that, of course.) BTW, ilikelegos, TheLogFather, gtoal, all of your Game of Life projects are amazing! Namely how to performance-tune Conway's Game of Life. Hi, I would like to pick up a topic that was discussed in this forum by ilikelegos, TheLogFather, gtoal and others in an old thread (which I didn't want to re-use due to its age, that's why the new posting).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |