Before now, I was storing each level in a two-dimensional array. This worked, but it had a problem. Once the level was built, there was no easy way to add squares to the top and left, and I eventually would have needed to solve that to implement Bit-Men and other programs that might add squares to the grid. I got around that by preemptively adding hundreds of empty squares to the edge of the array. Needless to say, this wasn’t ideal. It inflated the array, and the size of the grid was still limited.
I’ve now switched to using a dictionary, with each square indexed by its position. This means I can use negative numbers, which allows me to expand the grid indefinitely without adding superfluous elements. It’s a much better solution.
Also, if you’re reading this blog (and not a lot of people read this blog) then you might be wondering why my posts have slowed down recently. I think it’s because, near the beginning, there were a lot of big but relatively short tasks I could do, and progress was very visible. Now that I’ve gotten most of the low-hanging fruit, I’m left with tasks with a lower effort:result ratio, so each one takes longer. The law of diminishing returns.