示例#1
0
 public override StrategyResult Apply(Board board, ref string outInfo)
 {
     for (int k = 0; k < Board.size; k++)
     {
         IsolatedDoubleResult result = Apply(board.GetBox(k), Group.Box);
         if (result != null)
         {
             return(result);
         }
         result = Apply(board.GetRow(k), Group.Row);
         if (result != null)
         {
             return(result);
         }
         result = Apply(board.GetColumn(k), Group.Column);
         if (result != null)
         {
             return(result);
         }
     }
     return(null);
 }
示例#2
0
 private IsolatedDoubleResult Apply(Cell[] cells, Group groupType)
 {
     for (int i = 0; i < CellInfo.numbers; i++)
     {
         Cell cell1 = null;
         Cell cell2 = null;
         bool valid = true;
         foreach (Cell cell in cells)
         {
             if (CellHasNote(cell, i))
             {
                 if (cell1 == null)
                 {
                     cell1 = cell;
                 }
                 else if (cell2 == null)
                 {
                     cell2 = cell;
                 }
                 else
                 {
                     valid = false;
                 }
             }
         }
         if (cell2 == null || !valid)
         {
             continue;
         }
         for (int j = i + 1; j < CellInfo.numbers; j++)
         {
             valid = true;
             foreach (Cell cell in cells)
             {
                 if ((cell == cell1 || cell == cell2) != CellHasNote(cell, j))
                 {
                     valid = false;
                 }
             }
             if (valid)
             {
                 bool flag = false;
                 IsolatedDoubleResult result = new IsolatedDoubleResult(cells, cell1, cell2, i, j, groupType);
                 for (int k = 0; k < CellInfo.numbers; k++)
                 {
                     if (k != i && k != j)
                     {
                         if (CellHasNote(cell1, k))
                         {
                             ((Notes)cell1.info).Values[k] = false;
                             flag = true;
                         }
                         if (CellHasNote(cell2, k))
                         {
                             ((Notes)cell2.info).Values[k] = false;
                             flag = true;
                         }
                     }
                 }
                 if (flag)
                 {
                     return(result);
                 }
             }
         }
     }
     return(null);
 }