Search code examples
algorithmminesweeper

Minesweeper special case


I need to make Minesweeper for an assignment but I can't find any info on this particular case.

enter image description here

0 is an empty space, numbers are numbers and * is mine. Considering the top 0 and the right 0 are not touching eachother, clicking any of the 0 should reveal the diagonally adjacent 0? I did not encounter this situation when playing the game online.


Solution

  • If I select the spot in row 4, column 3 (1-based counting), that is a zero. This means that all 8 of the neighbors of that zero should be safe to reveal:

    213
    202
    201
    

    One of those neighbors (the one directly south of it, is also a zero, so its neighbors can be revealed, giving

    213
    202
    201
    210
    

    Now the bottom right is also a zero. Revealing its neighbors gives

    213
    202
    2011
    2100
     100
    

    That, in turn, reveals 3 additional zeros. The process continues until there are no more newly-revealed zeros to process, which should cover all the zeros in the bottom left quarter of the grid - any that can be reached from the original zero by a path passing through only zeroes, and using any of the 8 possible directions.