Minesweeper - Task 5


#1

Hi there,

I am having trouble with this exercise;

https://www.codecademy.com/courses/minesweeper/projects/adding-class-structure?program_content_id=0741dcebce95fb8a8875f99d2971f936&program_id=fc1cc76cbdee0831fda0677e3fd75ae6

In this task we are asked to incorporate the class model into the minesweeper code, which when called through the Game class will automatically generate a new Board, including parameters. This board is then checked for mines when the .playMove function is called.

There is a lot of code here, any help would be much appreciated!

class Game {
  constructor(numberOfRows, numberOfColumns, numberOfBombs){
    this._board = new Board(numberOfRows, numberOfColumns, numberOfBombs);
  }

Game.playMove(rowIndex, columnIndex){
  this.board.flipTile(rowIndex, columnIndex);
  if (this._board(playerBoard)[rowIndex][columnIndex] === 'B'){
    console.log("The game is lost!");
    this._board.print();
  } if (this.board(playerBoard).hasSafeTiles() === 0) { 
    console.log("You have won!");
  } else {
    console.log("Current Board:");
    this._board(playerBoard).print();
  }
}

}

class Board {
  contructor(nubmerOfRows, numberOfColumns, numberOfBombs) {
    this._numberOfBombs = numberOfBombs;
    this._numberOfTiles = numberOfColumns*numberOfRows;
    this._playerBoard = Board.generatePlayerBoard(numberOfRows, numberOfColumns);
    this._bombBoard = Board.generateBombBoard(numberOfRows, numberOfColumns, numberOfBombs);
  }
  
  get playerBoard(){
    return this._playerBoard();
  }
  
Board.flipTile(rowIndex, columnIndex){
  if (playerBoard[rowIndex][columnIndex] !== " ") {
    console.log("This tile has already by flipped!");
    return;
  } else if (this._bombBoard[rowIndex][columnIndex] == "B") {
    this._playerBoard[rowIndex][columnIndex] == "B";
  } else {
    this._playerBoard[rowIndex][columnIndex] = this.getNumberOfNeighborBombs(
      rowIndex,
      columnIndex
    );
    numberOfTiles -- ;
  }
}

getNumberOfNeighborBombs(rowIndex, columnIndex){
  const neighborOffsets = [
    [-1, -1],
    [-1, 0],
    [-1, 0],
    [0, -1],
    [0, 1],
    [1, -1],
    [1, 0],
    [1, 1]
  ];

  this._numberOfRows = this._bombBoard.length;
  this._numberOfColumns = this._bombBoard[1].length;
  var numberOfBombs = 0;
  neighborOffsets.forEach(offset => {
    const neighborRowIndex = rowIndex + offset[1];
    const neighborColumnIndex = columnIndex + offset[0];
    if (
      neighborRowIndex >= 0 &&
      neighborRowIndex < numberOfRows &&
      neighborColumnIndex >= 0 &&
      neighborColumnIndex < numberOfColumns
    ) {
      if (bombBoard[neighborRowIndex][neighborColumnIndex] == "B") {
        numberOfBombs++;
      }
    }
  });
  return numberOfBombs;
}

hasSafeTiles(){
  return this._numberOfTiles !== this._numberOfBombs;
}

print(board){
  console.log(board.map(row => row.join(" | ")).join("\n"));
}

static generatePlayerBoard( numberOfRows, numberOfColumns){
  var board = [];
  for (let i = 0; i < this._numberOfRows; i++) {
    var row = [];
    for (let j = 0; j < this._numberOfColumns; j++) {
      row.push(" ");
    }
    board.push(row);
  }
  return board;
}



 static generateBombBoard(numberOfRows, numberOfColumns,numberOfBombs){
  var board = [];
  for (let i = 0; i < this._numberOfRows; i++) {
    var row = [];
    for (let j = 0; j < this._numberOfColumns; j++) {
      row.push(" ");
    }
    board.push(row);
     }
  }
}

var numberOfBombsPlaced = 0;
  while (numberOfBombsPlaced < numberOfBombs) {
    var randomRowIndex = Math.floor(numberOfRows * Math.random());
    var randomColumnIndex = Math.floor(numberOfColumns * Math.random());
    if (board[randomRowIndex][randomColumnIndex] !== "B") {
      board[randomRowIndex][randomColumnIndex] = "B";
      numberOfBombsPlaced++;
    }
  }
  return board;
};

  const numberOfRows = bombBoard.length;
  const numberOfColumns = bombBoard[1].length;
  var numberOfBombs = 0;
  neighborOffsets.forEach(offset => {
    const neighborRowIndex = rowIndex + offset[1];
    const neighborColumnIndex = columnIndex + offset[0];
    if (
      neighborRowIndex >= 0 &&
      neighborRowIndex < numberOfRows &&
      neighborColumnIndex >= 0 &&
      neighborColumnIndex < numberOfColumns
    ) {
      if (bombBoard[neighborRowIndex][neighborColumnIndex] == "B") {
        numberOfBombs++;
      }
    }
  });
  return numberOfBombs;
};

const g = new Game( 3, 3, 3);

g.playMove( 0, 0);

#2

In something this large, finding errors on sight is near impossible, even after scanning thousands of lines of code with a critical eye. The long variable names always throw me for a loop and pretty much halt me in my tracks until I refactor the code and look for weaknesses.

Consider this refactoring of the loops you use to generate the boards.

 > s = new Array(11).join(' ,').split(',').slice(0, 10)
=> [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ]
 > s.length
=> 10
 > 

Above I have arbitrarily aimed for a board width of 10. Because of the construction method it took a tiny bit of finagling but it sorts itself out. We get the desired output without running a loop.

static generateBoard(numberOfRows, numberOfColumns) {
    board = [];
    while (numberOfRows-- > 0) {
        board.push(new Array(numberOfColumns + 1).join(' ,').split(',').slice(0, numberOfColumns));
    }
    return board;
}

Both the player and bomb board can be created from this model.


Consider that we can eliminate the other loop with further refactoring:

const genBoard = (rows, cols) => Array(rows).fill(Array(cols).fill(' '));

Edit: Not so. Creates duplicate references. Use the while loop, instead.

Now we have a simple utility that can replace more than a dozen lines of code.

static generatePlayerBoard(numberOfRows, numberOfColumns) {
    return Board.genBoard(numberOfRows, numberOfColumns);
}
static generateBombBoard(numberOfRows, numberOfColumns, numberOfBombs) {
    let board = Board.genBoard(numberOfRows, numberOfColumns);
    // ...
}

Now it is possible to see that we can actually eliminate the generatePlayerBoard method altogether and just call the genBoard method directly from the constructorā€¦

class Board {
  constructor (numberOfRows, numberOfColumns, numberOfBombs) {
    this._playerBoard = Board.genBoard(numberOfRows, numberOfColumns);
    // ...
  }
  static genBoard (rows, cols) {
     return Array(rows).fill(Array(cols).fill(' '));
  }
  set playerBoard (param) {
    // ...
  }
  get playerBoard () {
    return this._playerBoard;
  }
  // ...
}

Note that four of your errors were discovered in this process.

We may have strayed from the instructions but it never hurts to experiment, and test, test, test (which is how we found both your errors and our own).

See the board generatorā€¦

https://repl.it/NChd


Native Browser JavaScript
   
[ 99, 97, 82, 80, 77, 67, 66, 59, 53, 48, 46, 41, 32, 26, 24, 21, 19, 16, 13, 2 ]
[ [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ] ] 20
[ [ ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', '*', ' ', ' ', '*', ' ', ' ', '*' ],
  [ ' ', '*', ' ', ' ', '*', ' ', '*', ' ', ' ', ' ' ],
  [ ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', '*', ' ', ' ', ' ', ' ', '*', ' ', '*', ' ' ],
  [ ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', '*' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', '*', '*', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ' ],
  [ '*', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', '*' ] ] 20
=> undefined   

Reference 57 is interesting, nested betwixt four minesā€¦


#3

Slouching toward per elementā€¦

=> undefined
 > r = []
=> []
 > r.push(board.bombBoard[4].slice(6, 9))
=> 1
 > r.push(board.bombBoard[5].slice(6, 9))
=> 2
 > r.push(board.bombBoard[6].slice(6, 9))
=> 3
 > r
=> [ [ '*', ' ', '*' ], [ ' ', ' ', ' ' ], [ '*', '*', ' ' ] ]
 > let flag = r[1][1] == '*'
=> undefined
 > flag
=> false
 > board.bombBoard[5][7] = '4'
=> '4'
 > console.log(board.bombBoard)
 [ [ ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
   [ ' ', ' ', ' ', '*', ' ', ' ', '*', ' ', ' ', '*' ],
   [ ' ', '*', ' ', ' ', '*', ' ', '*', ' ', ' ', ' ' ],
   [ ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
   [ ' ', '*', ' ', ' ', ' ', ' ', '*', ' ', '*', ' ' ],
   [ ' ', ' ', ' ', '*', ' ', ' ', ' ', '4', ' ', '*' ],
   [ ' ', ' ', ' ', ' ', ' ', ' ', '*', '*', ' ', ' ' ],
   [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ' ],
   [ '*', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
   [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', '*' ] ]
=> undefined

#4

Too bad we donā€™t have the backstory to this project. I donā€™t want to reverse engineer the OP code so have continued to explore. Iā€™ve composed this as a static method, but in order to preserve the board first generated test with a declared function.

 > function analyzeBombBoard (board) { 
..     let rows = board.length; 
..     let cols = board[0].length; 
..     let zone, count; 
..     for (let row = 0; row < rows; row++) { 
..       for (let col = 0; col < cols; col++) { 
..         if (board[row][col] === '*') continue; 
..         zone = [];
..         count = 0; 
..         if (row === 0 && col === 0) { 
..           zone.push(board[0].slice(0,2)); 
..           zone.push(board[1].slice(0,2)); 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           board[0][0] = count ? count.toString(10) : '0'; 
..         } 
..       } 
..     } 
..   }
=> undefined
 > analyzeBombBoard(board.bombBoard)
=> undefined
 > console.log(board.bombBoard)
[ [ '0', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', '*', ' ', ' ', '*', ' ', ' ', '*' ],
  [ ' ', '*', ' ', ' ', '*', ' ', '*', ' ', ' ', ' ' ],
  [ ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', '*', ' ', ' ', ' ', ' ', '*', ' ', '*', ' ' ],
  [ ' ', ' ', ' ', '*', ' ', ' ', ' ', '4', ' ', '*' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', '*', '*', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ' ],
  [ '*', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', '*' ] ]
=> undefined   

The above demonstrates just one case, the top corner of the board. There are three other corners, two outer rows and two outer columns. Thatā€™s eight special cases. A switch will be the way to go on this.


#5

Hi mtf,

Thanks so much for these comments. I havenā€™t been able to give it much thought this week. I will take a look this weekend again!

J


#6

Have spent a little time roughing out the raw code for the eight special cases, and now just have to fill in the rest of the boardā€¦

 > function analyzeBombBoard (board) { 
..     let rows = board.length; 
..     let cols = board[0].length; 
..     let zone, count; 
..     for (let row = 0; row < rows; row++) { 
..       for (let col = 0; col < cols; col++) { 
..         if (board[row][col] === '*') continue; 
..         zone = [] 
..         count = 0; 
..         if (row === 0 && col === 0) { 
..           zone.push(board[0].slice(0,2)); 
..           zone.push(board[1].slice(0,2)); 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (row === 0 && col === cols - 1) { 
..           zone.push(board[0].slice(col - 1, cols)); 
..           zone.push(board[1].slice(col - 1, cols)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (row === 0) { 
..           zone.push(board[0].slice(col - 1, col + 2)); 
..           zone.push(board[1].slice(col - 1, col + 2)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][2] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           count += zone[1][2] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (row === rows - 1 && col === 0) { 
..           zone.push(board[row - 1].slice(0,2)); 
..           zone.push(board[row].slice(0,2)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (row === rows - 1 && col === cols - 1) { 
..           zone.push(board[row - 1].slice(col - 1, cols)); 
..           zone.push(board[row].slice(col - 1, cols)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (row === rows - 1) { 
..           zone.push(board[row - 1].slice(col - 1, col + 2)); 
..           zone.push(board[row].slice(col - 1, col + 2)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[0][2] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[1][2] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (col === 0) { 
..           zone.push(board[row - 1].slice(col, col + 2)); 
..           zone.push(board[row].slice(col, col + 2)); 
..           zone.push(board[row + 1].slice(col, col + 2)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][1] === '*' ? 1 : 0; 
..           count += zone[2][0] === '*' ? 1 : 0; 
..           count += zone[2][1] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..         else if (col === cols - 1) { 
..           zone.push(board[row - 1].slice(col -1, col + 2)); 
..           zone.push(board[row].slice(col -1, col + 2)); 
..           zone.push(board[row + 1].slice(col -1, col + 2)); 
..           count += zone[0][0] === '*' ? 1 : 0; 
..           count += zone[0][1] === '*' ? 1 : 0; 
..           count += zone[1][0] === '*' ? 1 : 0; 
..           count += zone[2][0] === '*' ? 1 : 0; 
..           count += zone[2][1] === '*' ? 1 : 0; 
..           board[row][col] = count ? count.toString(10) : board[row][col]; 
..           continue; 
..         } 
..       } 
..     } 
..   }
=> undefined
 > analyzeBombBoard(board.bombBoard)
=> undefined
 > console.log(board.bombBoard)
[ [ '0', '1', '*', '2', '1', '1', '1', '1', '1', '1' ],
  [ '1', '0', '0', '*', '0', '0', '*', '0', '0', '*' ],
  [ '1', '*', '0', '0', '*', '0', '*', '0', '0', '1' ],
  [ '2', '0', '*', '0', '0', '0', '0', '0', '0', '1' ],
  [ '1', '*', '0', '0', '0', '0', '*', '0', '*', '2' ],
  [ '1', '0', '0', '*', '0', '0', '0', '0', '0', '*' ],
  [ '0', '0', '0', '0', '0', '0', '*', '*', '0', '1' ],
  [ '1', '0', '0', '0', '0', '0', '0', '*', '0', '0' ],
  [ '*', '0', '*', '0', '0', '0', '0', '0', '0', '1' ],
  [ '1', '2', '1', '1', '0', '0', '1', '*', '2', '*' ] ]
=> undefined
 >

Itā€™s lot of code, but it works so far. The middle fill should be pretty straight forward, though I expect it will consume a bit a code. The rest of the game logic should also be pretty straight forward. Anxious to complete this experiment and when it becomes available, to compare it to the course outline.


#7

Here is the final caseā€¦

        } else {
          zone.push(board[row - 1].slice(col - 1, col + 2));
          zone.push(board[row].slice(col -1, col + 2));
          zone.push(board[row + 1].slice(col - 1, col + 2));
          count += zone[0][0] === '*' ? 1 : 0;
          count += zone[0][1] === '*' ? 1 : 0;
          count += zone[0][2] === '*' ? 1 : 0;
          count += zone[1][0] === '*' ? 1 : 0;
          count += zone[1][2] === '*' ? 1 : 0;
          count += zone[2][0] === '*' ? 1 : 0;
          count += zone[2][1] === '*' ? 1 : 0;
          count += zone[2][2] === '*' ? 1 : 0;
          board[row][col] = count ? count.toString(10) : board[row][col];
          continue;
        }

And the completed bombBoardā€¦

[ [ '0', '1', '*', '2', '1', '1', '1', '1', '1', '1' ],
  [ '1', '2', '3', '*', '2', '3', '*', '2', '1', '*' ],
  [ '1', '*', '3', '3', '*', '3', '*', '2', '1', '1' ],
  [ '2', '3', '*', '2', '1', '3', '2', '3', '1', '1' ],
  [ '1', '*', '3', '2', '1', '1', '*', '2', '*', '2' ],
  [ '1', '1', '2', '*', '1', '2', '3', '4', '3', '*' ],
  [ '0', '0', '1', '1', '1', '1', '*', '*', '3', '1' ],
  [ '1', '2', '1', '1', '0', '1', '3', '*', '2', '0' ],
  [ '*', '2', '*', '1', '0', '0', '2', '2', '3', '1' ],
  [ '1', '2', '1', '1', '0', '0', '1', '*', '2', '*' ] ]

Now the only challenge left to figure out is how the '0' is getting inserted when it should be ' '. Iā€™m trusting that work itself out once I refine the code.


Working prototype that generates a mine board and analyzes the vectors. Just click Run.

https://repl.it/NChd/3

The '0' did resolve itself with refinementā€¦

[ [ ' ', ' ', '1', '1', '1', '1', '*', '2', '2', '*' ],
  [ '1', '2', '4', '*', '2', '1', '2', '*', '2', '1' ],
  [ '1', '*', '*', '*', '2', ' ', '1', '1', '2', '1' ],
  [ '2', '3', '4', '3', '2', ' ', ' ', '1', '2', '*' ],
  [ '*', '1', '1', '*', '2', '1', '1', '2', '*', '4' ],
  [ '1', '1', '1', '1', '3', '*', '2', '2', '*', '*' ],
  [ '1', '1', '1', ' ', '2', '*', '3', '2', '3', '*' ],
  [ '1', '*', '1', ' ', '1', '2', '*', '1', '2', '2' ],
  [ '1', '1', '1', ' ', ' ', '1', '1', '1', '2', '*' ],
  [ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', '*' ] ]

Refactoredā€¦

count = (zone[0].concat(zone[1]).concat(zone[2])).filter(x => x === '*').length;
/*
count += zone[0][0] === '*' ? 1 : 0;
count += zone[0][1] === '*' ? 1 : 0;
count += zone[0][2] === '*' ? 1 : 0;
count += zone[1][0] === '*' ? 1 : 0;
count += zone[1][2] === '*' ? 1 : 0;
count += zone[2][0] === '*' ? 1 : 0;
count += zone[2][1] === '*' ? 1 : 0;
count += zone[2][2] === '*' ? 1 : 0;
*/

Had that been the first thing to come up, what test scenario would we have for it? The reason I like to work from the largest code base to start, and whittle it down when I know it to be true.

https://repl.it/NChd/5


#8
Analyze bomb layout
  static analyzeBombBoard (board) {
    const resolve = z => {
      if (z.length < 3) {
        z = z[0].concat(z[1]);
      } else {
        z = z[0].concat(z[1]).concat(z[2]);
      }
      return z.filter(x => x === '*').length;
    }
    let rows = board.length;
    let cols = board[0].length;
    let zone, count;
    for (let row = 0; row < rows; row++) {
      for (let col = 0; col < cols; col++) {
        if (board[row][col] === '*') continue;
        zone = []
        count = 0;
        switch (true) {
        case (row === 0 && col === 0):
          zone.push(board[0].slice(0,2));
          zone.push(board[1].slice(0,2));
          break;
        case (row === 0 && col === cols - 1):
          zone.push(board[0].slice(col - 1, cols));
          zone.push(board[1].slice(col - 1, cols));
          break;
        case (row === 0):
          zone.push(board[0].slice(col - 1, col + 2));
          zone.push(board[1].slice(col - 1, col + 2));
          break;
        case (row === rows - 1 && col === 0):
          zone.push(board[row - 1].slice(0,2));
          zone.push(board[row].slice(0,2));
          break;
        case (row === rows - 1 && col === cols - 1):
          zone.push(board[row - 1].slice(col - 1, cols));
          zone.push(board[row].slice(col - 1, cols));
          break;
        case (row === rows - 1):
          zone.push(board[row - 1].slice(col - 1, col + 2));
          zone.push(board[row].slice(col - 1, col + 2));
          break;
        case (col === 0):
          zone.push(board[row - 1].slice(col, col + 2));
          zone.push(board[row].slice(col, col + 2));
          zone.push(board[row + 1].slice(col, col + 2));
          break;
        case (col === cols - 1):
          zone.push(board[row - 1].slice(col - 1, col + 2));
          zone.push(board[row].slice(col - 1, col + 2));
          zone.push(board[row + 1].slice(col - 1, col + 2));
          break;
        default:
          zone.push(board[row - 1].slice(col - 1, col + 2));
          zone.push(board[row].slice(col -1, col + 2));
          zone.push(board[row + 1].slice(col - 1, col + 2));
        }
        count = resolve(zone);
        board[row][col] = count ? count.toString(10) : board[row][col];
      }
    }
  }

As predicted, this comes down to a switch.

https://repl.it/NChd/7


#9

Now that I have seen the error in my ways, Iā€™ve made the Game class an extension of Board, rather than the reverse which led to all kinds of problems for which I was remiss to solve.

The class has basic functionality which as yet is not resolving to a win or loss, but the mechanics of the board manipulation are starting to fall into place.

At present a Run will generate both the player board and the bomb board and instantiate a game instance of Game. Both boards will display (which is of course dev stage). The commands are simpleā€¦

game.clear()

will reveal in the player board the number of mines in the vicinity of the coordinate supplied by the two prompts. The row coordinate is entered first, followed by the column. The command has no effect on the bomb board.

game.playerBoard

is the getter that will retrievet the board for confirmation that a square has been revealed.

game.flag()

also prompts for row and column, and will verify that the square is a bomb and decrement the remaining bombs. If not a bomb, the remaining value is unchanged but the reveal value will be lost as it is replaced with an ā€˜Fā€™. Both boards are modified by this command.

game.remaining

is the getter to see the remaining count. It is not displayed at present but will be eventually. This is the only indication the player will have of whether or not they flagged an actual mine.

game.playerBoard
game.bombBoard

are the getters to confirm both changes have taken effect.

There are mods to the Board class, as one would expect, but I wonā€™t post that class here.

Game class
class Game extends Board {
  constructor (nRows, nCols, nBombs) {
    super(nRows, nCols, nBombs);
    this.board = new Board(nRows, nCols, nBombs)
    this._remaining = nBombs;
  }
  set remaining (x) {
    this._remaining -= x;
  }
  get remaining () {
    return this._remaining;
  }
  static getxy () {
    let y = Number(prompt(`Enter a row [0..${this._nRows}`));
    let x = Number(prompt(`Enter a column [0..${this._nCols}`));
    return [y, x];
  }
  clear () {
    this.playerBoard = Game.getxy();
  }
  flag () {
    let coords = Game.getxy();
    if (this.bombBoard[coords[0]][coords[1]] === '*') {
      this.remaining = 1;
    }
    this.bombBoard = coords;
    this.playerBoard = coords;
  }
}

https://repl.it/NChd/8


#10

Moving right along, Iā€™ve challenged myself to my first full game (in the dev stage, still):

=> undefined
 > game.flag(7,9)
 [ [ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' ],
   [ '0', '0', '0', '1', '1', '2', '2', '2', '1', '0' ],
   [ '2', '2', '1', '1', 'F', '2', 'F', 'F', '2', '1' ],
   [ 'F', 'F', '1', '1', '1', '2', '2', '3', '3', 'F' ],
   [ '2', '3', '3', '3', '2', '1', '1', '2', 'F', '2' ],
   [ '0', '1', 'F', 'F', 'F', '1', '1', 'F', '3', '2' ],
   [ '0', '1', '2', '3', '2', '2', '2', '4', 'F', '3' ],
   [ '1', '1', '0', '0', '0', '1', 'F', '4', 'F', 'F' ],
   [ 'F', '1', '1', '1', '1', '1', '3', 'F', '5', ' ' ],
   [ '1', '1', '1', 'F', '1', '0', '2', 'F', ' ', ' ' ] ]
=> undefined
 > game.remaining
=> 1
 > 

Now itā€™s a crap shoot to the finish. There is no clue to which one is the mine. I did leave a cheat in the code, game.remaining and setting a flag cannot lose one the game. only the reveal value in the flagged square. At this point, two of those squares have a '1' and one is the mine.

If I plant all flags for the remaining three, which will work, I will not lose, but I risk not flagging the last mine in my next move, which means I will have more flags than there are mines, an advantage that the program will eventually need to be weaned away from. Having got this far, though, where it is essentially rock, paper, scissors, I think it is fair to lean on the cheat just so we can test the win sequence.

Here I go to test my luckā€¦

game.clear(9,9)
'1'

Heads or tails, nowā€¦

 >  game.flag(8,9)
 [ [ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' ],
   [ '0', '0', '0', '1', '1', '2', '2', '2', '1', '0' ],
   [ '2', '2', '1', '1', 'F', '2', 'F', 'F', '2', '1' ],
   [ 'F', 'F', '1', '1', '1', '2', '2', '3', '3', 'F' ],
   [ '2', '3', '3', '3', '2', '1', '1', '2', 'F', '2' ],
   [ '0', '1', 'F', 'F', 'F', '1', '1', 'F', '3', '2' ],
   [ '0', '1', '2', '3', '2', '2', '2', '4', 'F', '3' ],
   [ '1', '1', '0', '0', '0', '1', 'F', '4', 'F', 'F' ],
   [ 'F', '1', '1', '1', '1', '1', '3', 'F', '5', 'F' ],
   [ '1', '1', '1', 'F', '1', '0', '2', 'F', ' ', '1' ] ]
 You flagged all the mines. Congratulations!
=> undefined
 > 

https://repl.it/NChd/9


#11

Introducing a play function that will give substance with user defined constraintsā€¦

const play = function(difficulty) {
  game = new Game(10, 10, difficulty ? 20 : 10);
  if (arguments[1]) {
    console.log(`Verbose Mode`);
    // jump to game loop function
  } else {
    console.log('Console Mode');
  }
  if (arguments[2]) {
    console.log(game.bombBoard);
  }
  console.log(game.playerBoard);
};
play();

The arguments are described in the code. It follows that to have a third argument, the other two must be set; for instance.

play(0, 0, 1);

Otherwise, no arguments are required by the caller.

play();

which gives us a easy difficulty with console mode commands and no bombBoard visibility, so weā€™re game on.


#12
Game on!
 Native Browser JavaScript
 > 
 Console Mode
 > game.clear(9,1)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ','0',' ',' ',' ',' ',' ',' ',' ',' ']]
 > game.clear(9,2)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ','0','0',' ',' ',' ',' ',' ',' ',' ']]
 > game.clear(9,3)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ','0','0','0',' ',' ',' ',' ',' ',' ']]
 > game.clear(9,4)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ','0','0','0','0',' ',' ',' ',' ',' ']]
 > game.clear(9,5)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(8,5)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','1',' ',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(8,4)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ','0','1',' ',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(7,5)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0',' ',' ',' ',' '],
  [' ',' ',' ',' ','0','1',' ',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(8,6)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0',' ',' ',' ',' '],
  [' ',' ',' ',' ','0','1','1',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(7,6)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0',' ',' ',' '],
  [' ',' ',' ',' ','0','1','1',' ',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(8,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0',' ',' ',' '],
  [' ',' ',' ',' ','0','1','1','2',' ',' '],
  [' ','0','0','0','0','1',' ',' ',' ',' ']]
 > game.clear(9,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0',' ',' ',' '],
  [' ',' ',' ',' ','0','1','1','2',' ',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(7,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0',' ',' '],
  [' ',' ',' ',' ','0','1','1','2',' ',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(8,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0',' ',' '],
  [' ',' ',' ',' ','0','1','1','2','2',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(8,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0',' ',' '],
  [' ',' ',' ',' ','0','1','1','2','2',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(7,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0',' ',' '],
  [' ',' ',' ',' ','0','1','1','2','2',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(7,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0','0',' '],
  [' ',' ',' ',' ','0','1','1','2','2',' '],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(8,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0','0',' '],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(7,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(6,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(5,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.clear(5,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ',' ']]
 > game.flag(9,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2',' ','F']] 9
 > game.flag(9,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1',' ','2','F','F']] 8
 > game.flag(9,6)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 7
 > game.clear(6,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(5,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(4,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(4,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 6
 > game.clear(3,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(2,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(3,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(2,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(3,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(2,7)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ',' '],
  [' ',' ',' ',' ',' ',' ',' ',' ','1',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(0,9)
 [[' ',' ',' ',' ',' ',' ',' ',' ',' ','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(0,8)
 [[' ',' ',' ',' ',' ',' ',' ',' ','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(0,7)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1',' '],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(1,9)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 5
 > game.clear(4,6)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(6,4)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ','0',' ',' ',' ','0','0'],
  [' ',' ',' ',' ',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(7,3)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ','0',' ',' ',' ','0','0'],
  [' ',' ',' ','0',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(6,2)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ','0',' ','0',' ',' ',' ','0','0'],
  [' ',' ',' ','0',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(5,1)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ','0',' ','0',' ',' ',' ','0','0'],
  [' ',' ',' ','0',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(7,1)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ','0',' ','0',' ',' ',' ','0','0'],
  [' ','1',' ','0',' ','0','0','0','0','0'],
  [' ',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(8,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ','0',' ','0',' ',' ',' ','0','0'],
  [' ','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(7,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 4
 > game.clear(6,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(5,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(4,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(4,1)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 3
 > game.clear(3,1)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(2,2)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ',' ',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,1)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ',' ','1','F'],
  [' ',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(2,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,0)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1',' ',' ',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,2)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1',' ',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,3)
 [[' ',' ',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(0,1)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 2
 > game.clear(3,3)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ','1',' ',' ',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(3,5)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ','1',' ','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ',' ',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(5,4)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ','1',' ','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ','0',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(3,4)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ',' ',' ','0','1','1'],
  [' ','1',' ','1','F','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ','0',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 1
 > game.clear(2,5)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ',' ',' ',' ','1','F'],
  ['0',' ','0',' ',' ','1',' ','0','1','1'],
  [' ','1',' ','1','F','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ','0',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.clear(1,5)
 [[' ','F',' ',' ',' ',' ',' ','0','1','1'],
  ['1','1','1','0',' ','1',' ',' ','1','F'],
  ['0',' ','0',' ',' ','1',' ','0','1','1'],
  [' ','1',' ','1','F','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ','0',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']]
 > game.flag(0,5)
 [[' ','F',' ',' ',' ','F',' ','0','1','1'],
  ['1','1','1','0',' ','1',' ',' ','1','F'],
  ['0',' ','0',' ',' ','1',' ','0','1','1'],
  [' ','1',' ','1','F','1',' ','0','1','1'],
  ['1','F',' ',' ',' ',' ','0',' ','1','F'],
  ['1','1',' ',' ','0',' ',' ','0','1','1'],
  ['1',' ','0',' ','0',' ',' ',' ','0','0'],
  ['F','1',' ','0',' ','0','0','0','0','0'],
  ['1',' ',' ',' ','0','1','1','2','2','2'],
  [' ','0','0','0','0','1','F','2','F','F']] 0
 You flagged all the mines. Congratulations!

#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.