Entropy calculations should involve probabilities, not rough frequencies. These values are passed to log which gives different sign for probabilities (<1) and frequencies (>1).
I don't see how equations in the original implementation relate to entropy, use Shannon formulation instead.
Current implementation runs into rounding issues due to the use of int instead of double.
All in all this impacts the selection of the next cell to collapse. With the fix the frequencies of tiles in the output image should match that of the input image.
log
which gives different sign for probabilities (<1) and frequencies (>1).int
instead ofdouble
.All in all this impacts the selection of the next cell to collapse. With the fix the frequencies of tiles in the output image should match that of the input image.