Ejemplo n.º 1
0
        public static bool ReadyCells(Cell[,] cells)
        {
            bool hasChanged = false;

            for (int i = 0; i < cells.GetLength(0); i++)
            {
                for (int j = 0; j < cells.GetLength(1); j++)
                {
                    if (!cells[i, j].IsReady && (int)cells[i, j].CellValue != 4)
                    {
                        Cell cell90  = Cell.Turn90(cells[i, j]),
                             cell180 = Cell.Turn90(cell90),
                             cell270 = Cell.Turn90(cell180);
                        hasChanged = (int)cells[i, j].CellValue switch
                        {
                            3 when SubMultiSolvingRules.SubReadyThreeCell(cells[i, j]) ||
                            SubMultiSolvingRules.SubReadyThreeCell(cell90) ||
                            SubMultiSolvingRules.SubReadyThreeCell(cell180) ||
                            SubMultiSolvingRules.SubReadyThreeCell(cell270) => true,
                            2 when SubMultiSolvingRules.SubReadyTwoCell(cells[i, j]) ||
                            SubMultiSolvingRules.SubReadyTwoCell(cell90) ||
                            SubMultiSolvingRules.SubReadyTwoCell(cell180) ||
                            SubMultiSolvingRules.SubReadyTwoCell(cell270) => true,
                            1 when SubMultiSolvingRules.SubReadyOneCell(cells[i, j]) ||
                            SubMultiSolvingRules.SubReadyOneCell(cell90) ||
                            SubMultiSolvingRules.SubReadyOneCell(cell180) ||
                            SubMultiSolvingRules.SubReadyOneCell(cell270) => true,
                            _ => hasChanged
                        };
                    }
                }
            }

            return(hasChanged);
        }
Ejemplo n.º 2
0
        public static bool ReadyDots(Dot[,] dots)
        {
            bool hasChanged = false;

            foreach (var dot in dots)
            {
                if (dot.IsReady)
                {
                    continue;
                }
                Dot dot90 = Dot.Turn90(dot), dot180 = Dot.Turn90(dot90), dot270 = Dot.Turn90(dot180);
                if (SubMultiSolvingRules.SubSetForbidsOfConnectedDot(dot)
                    | SubMultiSolvingRules.SubSetForbidsOfConnectedDot(dot90)
                    | SubMultiSolvingRules.SubSetForbidsOfConnectedDot(dot180)
                    | SubMultiSolvingRules.SubSetForbidsOfConnectedDot(dot270)
                    | SubMultiSolvingRules.SubSetLineOfForbiddenDot(dot)
                    | SubMultiSolvingRules.SubSetLineOfForbiddenDot(dot90)
                    | SubMultiSolvingRules.SubSetLineOfForbiddenDot(dot180)
                    | SubMultiSolvingRules.SubSetLineOfForbiddenDot(dot270)
                    | SubMultiSolvingRules.SubDotWithThreeForbidden(dot)
                    | SubMultiSolvingRules.SubDotWithThreeForbidden(dot90)
                    | SubMultiSolvingRules.SubDotWithThreeForbidden(dot180)
                    | SubMultiSolvingRules.SubDotWithThreeForbidden(dot270))
                {
                    dot.IsReady = true;
                    hasChanged  = true;
                }
            }

            return(hasChanged);
        }