mxgmn / WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics
Other
23.18k stars 1.24k forks source link

Unit tests #24

Closed nanodeath closed 7 years ago

nanodeath commented 7 years ago

It would be a good idea to have some unit tests on this code. Ensure that given an input and some seed, it does a pixel-by-pixel comparison of that output with an expected output image. Would make changes much safer. (I have a few examples in Kollapse, if that helps any).

mxgmn commented 7 years ago

I prefer not to write unit tests for probabilistic functions. One can fix seeds, but they will still be completely unverifiable for humans. And if I change the algorithm a bit, even if I don't change it but just optimize the Observe() method to not call RNG so often, I would need completely new unit tests. You can take the other approach in Kollapse of course.

nanodeath commented 7 years ago

You wouldn't need a new unit test...you'd just update the expected image to match the new output. Otherwise, there's really no way to make changes with confidence that you didn't break something.

d-kr commented 7 years ago

Or one could just check the hash of the bitmap (-data). Then they need to change only one line if they need to.