Skip to content

Latest commit

 

History

History
22 lines (22 loc) · 1.06 KB

File metadata and controls

22 lines (22 loc) · 1.06 KB
  • make minesweeper
  • code a simple one cell solver:
    • COND 1: if a cell's value == flags around it, clear all unrevealed, unflagged tiles
    • COND 2: if a cell's value == flags around it + unrevealed tiles, flag all unrevealed tiles
  • now we can run our solve:
    • open a random cell
    • add all "new" tiles to the queue
    • take something off the queue:
      • run the simple one cell solver
      • all revealed tiles get added onto the queue
      • repeat
  • Optimization #1:
    • if we flag a tile, surrounding cells should also be added to th queue because their effective mine count changed
  • Optimization #2:
    • use a stack instead of a queue to match human solving patterns
  • Optimization #3:
    • if we reveal a tile, neighbouring cells may now have COND 2 fulfilled, so we need to add it to the queue
  • Optimization #4:
    • subset/reduction, this solves 1-1-safe and 1-2-flag patterns
  • Optimization #5:
    • instead of only looking at neighbours, look at cells 2 away as well. unrevealed cells can be shared between neighbours 2 away (e.g. a ? b instead of just a b)