Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize grid updates #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

gverger
Copy link

@gverger gverger commented Jul 21, 2022

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
wfc-25-1

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

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

gverger added 2 commits July 21, 2022 23:32
instead of going through all cells to get their tile options, we keep a
cache of options, and only modify cells that might have changed.

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 even better than going through the old grid because it propagates
changes until we come to a stable state. In the old way, we only check
cells once, according to the state at t-1, which can miss some option
reductions and lead to infeasibility.
@gverger gverger mentioned this pull request Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant