コード例 #1
0
ファイル: Trap.cs プロジェクト: blushiemagic/SudokuSolver
        public override StrategyResult Apply(Board board, ref string outInfo)
        {
            TrapResult result = Apply(board, box => board.GetBox(box), cell => cell.Row, Group.Box, Group.Row);

            if (result != null)
            {
                return(result);
            }
            result = Apply(board, box => board.GetBox(box), cell => cell.Column, Group.Box, Group.Column);
            if (result != null)
            {
                return(result);
            }
            result = Apply(board, box => board.GetRow(box), cell => cell.Box, Group.Row, Group.Box);
            if (result != null)
            {
                return(result);
            }
            result = Apply(board, box => board.GetColumn(box), cell => cell.Box, Group.Column, Group.Box);
            if (result != null)
            {
                return(result);
            }
            return(null);
        }
コード例 #2
0
ファイル: Trap.cs プロジェクト: blushiemagic/SudokuSolver
 private TrapResult Apply(Board board, Func <int, Cell[]> getGroup, Func <Cell, int> trapID,
                          Group groupType, Group trapType)
 {
     for (int k = 0; k < Board.size; k++)
     {
         Cell[] group = getGroup(k);
         for (int num = 0; num < CellInfo.numbers; num++)
         {
             TrapResult result = Apply(board, group, num, trapID, groupType, trapType);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }