Previously I was taking a very OO approach to the idea. Making each cell an object with its x and y position, the number in the cell, wether it was a bomb or not and if there was a flag on the cell. Note that at the time it was designed as a single player version so just a boolean value for the flag state was sufficient.

This naive approach quickly ran into scaling issues. Just generating a 100x100 field was already taking up too much space.

Chunking

Instead of generating a cell object for each cell i’d create chunks instead. Each chunk would contain an array of the cells inside of the chunk. Numbers would store the number on the cell, and labels could denote if there was a bomb or a flag. This approach reduced the amount of objects floating around by a large factor.

Border calculations

The final issue I had before I gave up on the project was calculating the values of the border tiles. In order to generate the numbers on the border of a chunk we also need to generate the surrounding 8 chunks. the four orthogonal adjacent ones for the edges and the four corner chunks are also required to properly calculate the corner values.

At this point it got a bit too complicated for the amount of effort I wanted to put into the project