using System.Collections.Generic;
private readonly int _value;
public bool IsMine => _value < 0;
public bool IsEmpty => _value == 0;
public int Value => _value;
public override string ToString()
return IsMine ? "*" : Value.ToString();
public Square[,] Squares { get; private set; }
public Minesweeper(int size, int mines)
private void Init(int size)
private List<Square> GetNeighbours(int row, int column)
return new List<Square>();
private int CountMines(List<Square> neighbours)
private void CountMines()
private void FillRandom(int mines)
var maxMines = Squares.GetLength(0) * Squares.GetLength(1) / 2;
var randomRow = r.Next() % Squares.GetLength(0);
var randomColumn = r.Next() % Squares.GetLength(1);
if (Squares[randomRow,randomColumn] != null && Squares[randomRow,randomColumn] .IsMine)
Squares[randomRow,randomColumn] = new Square(-1);
public override string ToString()
var sb = new StringBuilder();
for (var row = 0; row < Squares.GetLength(0); row++)
for (var column = 0; column < Squares.GetLength(1); column++)
if (Squares[row, column] == null)
sb.Append(Squares[row,column]);
static void Main(string[] args)
var minesweeper = new Minesweeper(10, 10);
Console.WriteLine(minesweeper);