A small change to one line of code tripled the speed of my level generator, but at a cost: the levels themselves were affected, but it wasn’t until recently that I figured out why.
Phantom dots.
The change effectively fixed a bug that could result in the line drawing algorithm think there are a pair of dots that isn’t there.
How much difference can two dots make? Below is an example:
The first grid shows how a typical line drawing algorithm would draw a line connecting the two purple dots. The second grid shows how the line is drawn with the red dots.
Read more about this change and it’s effect on the Phantom Dots page.