Exemple #1
0
        private double GetMaxPercentCell(ListСell cells)
        {
            var maxPercentCell = 0.0;

            foreach (Сell numberField in cells)
            {
                if (VisibleСell.IsPresent(numberField))
                {
                    var aroundCells = VisibleСell.GetAroundCellsNoTags(numberField, size);
                    var countFlags  = 0;

                    foreach (Сell aroundField in aroundCells)
                    {
                        if (MarkCell.IsPresent(aroundField))
                        {
                            countFlags++;
                        }
                    }

                    var countNoFlags = aroundCells.Count - countFlags;

                    var percentCell = 1.0 * (VisibleСell[numberField.Row, numberField.Column].Value - countFlags) / countNoFlags;

                    if (maxPercentCell < percentCell)
                    {
                        maxPercentCell = percentCell;
                    }
                }
            }

            return(maxPercentCell);
        }
Exemple #2
0
        public Сell GetMark()
        {
            foreach (Сell cell in VisibleСell)
            {
                if (cell.Value != 0)
                {
                    var aroundCells = VisibleСell.GetAroundCellsNoTags(cell, size);

                    if (cell.Value == aroundCells.Count)
                    {
                        foreach (Сell field in aroundCells)
                        {
                            if (!MarkCell.IsPresent(field))
                            {
                                return(new Сell(field.Row, field.Column, true));
                            }
                        }
                    }
                }
            }

            return(Get100Choice());
        }
Exemple #3
0
        public Сell Get100Choice()
        {
            foreach (Сell cell in VisibleСell)
            {
                if (cell.Value != 0)
                {
                    var aroundCells = VisibleСell.GetAroundCellsNoTags(cell, size);

                    if (cell.Value != aroundCells.Count)
                    {
                        var countFlags = 0;

                        foreach (Сell field in aroundCells)
                        {
                            if (MarkCell.IsPresent(field))
                            {
                                countFlags++;
                            }
                        }

                        if (cell.Value == countFlags)
                        {
                            foreach (Сell field in aroundCells)
                            {
                                if (!MarkCell.IsPresent(field))
                                {
                                    return(field);
                                }
                            }
                        }
                    }
                }
            }

            return(GetBestRandomChoice());
        }