robert / wavefunction-collapse

The Wavefunction Collapse Algorithm explained very clearly
https://robertheaton.com/2018/12/17/wavefunction-collapse-algorithm/
The Unlicense
290 stars 45 forks source link

Address #6: use "row major" convention for matrix access #7

Closed scan-lan closed 2 years ago

scan-lan commented 2 years ago

Addresses issue #6

Hiya, Robert,

Love your blog, I came across it whilst looking for wave function collapse stuff. Your post about it is the first result on google when you search "wave function collapse algorithm"—for me, at least— and so I think it'd be good to ensure the code is as clear as possible.

In a few places, matrices were indexed like [x][y], but in other places the inner-lists were referred to as rows.

This treats the inner lists in the matrices as rows, which is more common than the current implementation. This means all indices are changed to [y (row)][x (coefficient/value)]. I tried to touch the code as little as possible besides that.

Thanks for the code, the post, and the blog in general, Luke

scan-lan commented 2 years ago

I've got a follow-up PR (#8) which adds type hints. You can merge that after this one, if you like. I think adding them helped me understand/adapt the code a bit quicker.

robert commented 2 years ago

Thanks and sorry for the delay merging! Looks great.

scan-lan commented 2 years ago

No worries, it was my pleasure.