Ejemplo n.º 1
0
 public void LoadAvailableMoves()
 {
     for (int x = 0; x < 9; x++)
     {
         for (int y = 0; y < 9; y++)
         {
             var moves = game.AvailableRanks(x, y);
             SudokuBoard.SetAvailableRanks(x, y, moves);
         }
     }
 }
Ejemplo n.º 2
0
        public void Test_Sudoku_Available()
        {
            Sudoku Sudoku = new Sudoku();

            List <int> available = Sudoku.AvailableRanks(4, 4);

            Assert.AreEqual(9, available.Count);

            Sudoku[4, 1] = new CellContent(1);

            var col = Sudoku.GetColumnAt(4);

            Assert.AreEqual(8, col.AvailableRanks().Count);

            available = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(8, available.Count);

            Sudoku[1, 4] = new CellContent(1);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(8, available.Count);

            Sudoku[2, 4] = new CellContent(2);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(7, available.Count);

            Sudoku[4, 8] = new CellContent(3);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(6, available.Count);

            Sudoku[3, 3] = new CellContent(4);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(5, available.Count);

            Sudoku[5, 5] = new CellContent(5);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(4, available.Count);

            Sudoku[7, 4] = new CellContent(6);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(3, available.Count);

            Sudoku[4, 7] = new CellContent(7);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(2, available.Count);

            Sudoku[3, 5] = new CellContent(8);
            available    = Sudoku.AvailableRanks(4, 4);
            Assert.AreEqual(1, available.Count);

            Assert.AreEqual(9, available[0]);
        }
Ejemplo n.º 3
0
        public void Test_Sudoku_Available_T2()
        {
            Sudoku Sudoku = new Sudoku();

            List <int> available = Sudoku.AvailableRanks(0, 6);

            Assert.AreEqual(9, available.Count);

            Sudoku[0, 6] = new CellContent(1);
            available    = Sudoku.AvailableRanks(0, 6);
            Assert.AreEqual(0, available.Count);

            available = Sudoku.AvailableRanks(1, 7);
            Assert.AreEqual(8, available.Count);

            // check if rank 1 is available:
            int cnt = available.Where(q => q == 1).Count();

            Assert.AreEqual(0, cnt);

            Assert.IsFalse(Sudoku.ValidateMove(1, 7, 1));
        }