Optimize grid updates
Instead of going through all cells to get their tile options, we keep the grid (like a cache of options), and only modify cells that might have changed, leaving aside cells we are sure are unchanged.
Idea: We start from the picked cell, and we check its neighbours. For each neighbour (up, right, down, left), if the list of options has changed, we add its own neighbours to the list of cells to check. If it didn't change, we just skip its neighbours.
It is more accurate than going through the old grid because it propagates changes until we arrive to a stable state. In the old way, we only check cells once, according to the state at t-1. It seems to me it is reducing the options of the last pick only.
Bonus: since the drawing of cells now a lot of time compared to choosing the next tile, we can have several updates per draw, which speeds considerably the process.
Here with 1 update per tick, DIM = 25, size = 400x400

Here with 10 updates per tick, DIM = 50, size = 800x800

Here with 1000 updates per tick, DIM = 200, size = 800x800

Many apologies!!! I know it's been almost 3 years since these PRs! I am releasing a new video next week on the overlapping model and did some work to refactor this repository. Would you like to resubmit this? I'm open to incorporating it into the new structure. If you (very understandably) don't have time to look at this again, I'm glad to sort it out!
Hey @shiffman , don't apologize, that's the nature of open source, you never asked me to add anything to your repo anyway, so you don't owe me anything 😄
I solved the conflicts, it's been a while I didn't touch any javascript, but fortunately your changes were small
Keep up the good work and the good mood!
This is great! I'm thinking of doing a follow-up video where I'm go over a whole variety of improvements and incorporate them into the examples. (The new "overlapping model" video is coming out on Tuesday.) I'm going to leave this open for now and link to it from the community contributions in the README. Then when I do the new video I'll go over the code and merge this in!
Added to the README in #46!