Exemple #1
0
 /// <summary>
 /// Check the number of MainBlocks that may own the given Cell.
 /// Can proves no solution, mark a Cell as owned or set a possible block as a solution to a MainBlock.
 /// </summary>
 private bool CountCellPossibleOwners(ICell cell)
 {
     //There are no MainBlocks that can contain the Cell, hence there can be no solution.
     if (cell.GetPossibleMainBlocks.Count == 0)
     {
         return(true);
     }
     //There is only 1 MainBlock that can contain this Cell, hence the Cell must be owned by said MainBlock.
     //If there is also only 1 PossibleOwner for this MainBlock, that PossibleBlock must be the solution to the MainBlock.
     if (cell.GetPossibleMainBlocks.Count == 1)
     {
         if (cell.GetPossibleOwners[cell.GetPossibleMainBlocks.First.Value].Count == 1)
         {
             if (_ownershipSetter.SetPossibleBlockAsSolution(AdditionalMethods.CreatePossibleBlockFromIndex(
                                                                 cell.GetPossibleMainBlocks.First.Value, _solutionTracker.BlockDimensionSets, cell.GetPossibleOwners[cell.GetPossibleMainBlocks.First.Value].First.Value)))
             {
                 return(true);
             }
         }
         else
         {
             if (_ownershipSetter.MarkCellAsOwned(cell, cell.GetPossibleMainBlocks.First.Value))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 private bool CheckMainBlocks(List <IMainBlock> mainBlocks)
 {
     if (mainBlocks == null)
     {
         return(true);
     }
     else
     {
         foreach (IMainBlock mainBlock in mainBlocks)
         {
             foreach (int possibleBlock in mainBlock.PossibleBlocks)
             {
                 SetPossibleBlockAsSolution(AdditionalMethods.CreatePossibleBlockFromIndex(mainBlock, _solutionTracker.BlockDimensionSets, possibleBlock));
             }
         }
     }
     return(false);
 }