コード例 #1
0
ファイル: Program.cs プロジェクト: sbknick/MinesweeperSolver
        public static void Main()
        {
            using (var map = new WebMap())
            {
                var solver     = new MinesweeperSolver(map);
                var screenshot = solver.Run();
            }


            //    var map = WebMap.Load();

            //    var mapHandler = new MapHandler();
            //    var solver = new SolverEngine(
            //        new SimpleEngine(),
            //        new TrickEngine(mapHandler));

            //    while (true)
            //    {
            //        foreach (var step in solver.RunStep()) { }
            //    }

            //    //var solver = new MinesweeperSolver(new MinesweeperDriver(new ChromeDriver()));

            //    //var result = await solver.Run();
        }
コード例 #2
0
        //[TestProperty("MiddleSquareTestingWithoutMines", "0")]
        public void GetLocationValue_SquareInMiddleWithoutMines_Success()
        {
            int[,] inputBoard = new int[, ] {
                { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { -1, 0, -1 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(3, 3, inputBoard);

            int locationValue = minesweeperSolver.GetLocationValue(1, 1);

            Assert.AreEqual(0, locationValue);
        }
コード例 #3
0
        //[TestProperty("CornerSquareTesting", "5")]
        public void GetLocationValue_SquareAllSurroundedByMines_Success()
        {
            int[,] inputBoard = new int[, ] {
                { -1, 0, -1 }, { -1, -1, -1 }, { 0, 0, 0 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(3, 3, inputBoard);

            int locationValue = minesweeperSolver.GetLocationValue(0, 1);

            Assert.AreEqual(5, locationValue);
        }
コード例 #4
0
        //[TestProperty("BottomCornerSquareTesting", "1")]
        public void GetLocationValue_BottomCornerSquareWithMine_Success()
        {
            int[,] inputBoard = new int[, ] {
                { -1, 0, 0 }, { 0, -1, 0 }, { 0, 0, 0 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(3, 3, inputBoard);

            int locationValue = minesweeperSolver.GetLocationValue(2, 2);

            Assert.AreEqual(1, locationValue);
        }
コード例 #5
0
        public void SolveGame_With_Success()
        {
            int[,] inputBoard = new int[, ] {
                { -1, -1, -1, 0, -1 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(3, 3, inputBoard);

            //int locationValue = minesweeperSolver.GetLocationValue(10, 10);

            Assert.Throws <IndexOutOfRangeException>(() => minesweeperSolver.GetLocationValue(10, 10));
        }
コード例 #6
0
        //[TestProperty("WithOneRow", "")]
        public void SolveGame_WithOneRow_Success()
        {
            int[,] inputBoard = new int[, ] {
                { -1, -1, -1, 0, -1 }
            };
            int[,] expectedOutputBoard = new int[, ] {
                { -1, -1, -1, 2, -1 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(5, 1, inputBoard);

            int[,] outputBoard = minesweeperSolver.SolveGame();

            CollectionAssert.AreEqual(expectedOutputBoard, outputBoard);
        }
コード例 #7
0
        //[TestProperty("WithOneColumn", "")]
        public void SolveGame_WithOneColumn_Success()
        {
            int[,] inputBoard = new int[, ] {
                { -1 }, { -1 }, { -1 }, { 0 }, { -1 }
            };
            int[,] expectedOutputBoard = new int[, ] {
                { -1 }, { -1 }, { -1 }, { 2 }, { -1 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(1, 5, inputBoard);

            int[,] outputBoard = minesweeperSolver.SolveGame();

            CollectionAssert.AreEqual(expectedOutputBoard, outputBoard);
        }
コード例 #8
0
        //[TestProperty("SolveBoardWithEmptyMines", "All Zeors")]
        public void SolveGame_WithEmptyMines_Success()
        {
            int[,] inputBoard = new int[, ] {
                { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
            };
            int[,] expectedOutputBoard = new int[, ] {
                { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
            };
            MinesweeperSolver minesweeperSolver = new MinesweeperSolver(3, 3, inputBoard);

            int[,] outputBoard = minesweeperSolver.SolveGame();

            CollectionAssert.AreEqual(expectedOutputBoard, outputBoard);
        }