public PercolationStats(int N, int T) { var rnd = new Random(); for (int k = 0; k < T; k++) { Console.WriteLine("Iteration {0}", k); _percolation = new Percolation(N); var countOpened = 0; do { var i = rnd.Next(1, N + 1); var j = rnd.Next(1, N + 1); if (_percolation.IsOpen(i, j)) continue; _percolation.Open(i, j); countOpened++; } while (!_percolation.Percolates()); Console.WriteLine("Count opened {0}", countOpened); _mean = (_mean + (double) countOpened/(N*N)) / 2; Console.WriteLine("mean {0}", _mean); } }
public void Open_cell_should_open_it() { // arrange var percolation = new Percolation(5); // act percolation.Open(2, 3); // assert Assert.IsTrue(percolation.IsOpen(2, 3)); }
public void Open_cell_on_the_right_bottom_corner() { // arrange var percolation = new Percolation(5); // act percolation.Open(5, 5); // assert Assert.IsTrue(percolation.IsOpen(5, 5)); }