Beispiel #1
0
        public AnalyzeData Clone()
        {
            var clone = new AnalyzeData(Value);

            if (_analyzed)
            {
                clone.Analyzed();
            }
            return(clone);
        }
Beispiel #2
0
        private void pattern11Row()
        {
            int row = 0;

            foreach (var rowlist in rowNumbers)
            {
                if (rowlist.IsAnalyzed())
                {
                    row++;
                    continue;
                }
                rowlist.AnalyzeDatas.Reverse();

                // 塗られている連続したマスを数える
                List <List <BitmapData> > data = new List <List <BitmapData> >();
                {
                    List <BitmapData> dataList = new List <BitmapData>();
                    for (int col = 0; col < colNumbers.Count; col++)
                    {
                        if (_bitmapData[row, col].IsPainted() == true)
                        {
                            dataList.Add(_bitmapData[row, col]);
                        }
                        else
                        {
                            if (dataList.Count != 0)
                            {
                                data.Add(dataList);
                                dataList = new List <BitmapData>();
                            }
                        }
                    }
                    if (dataList.Count != 0)
                    {
                        data.Add(dataList);
                    }

                    if (data.Count == 0)
                    {
                        row++;
                        rowlist.AnalyzeDatas.Reverse();
                        continue;
                    }
                }

                List <BitmapData> targetDataList = null;
                // 最大の物を取得する
                foreach (var datalist in data)
                {
                    if (targetDataList == null)
                    {
                        targetDataList = datalist;
                    }
                    else if (targetDataList.Count < datalist.Count)
                    {
                        targetDataList = datalist;
                    }
                }

                AnalyzeData targetRowList = null;
                bool        sameflg       = false;
                foreach (var rowdata in rowlist.AnalyzeDatas)
                {
                    if (targetRowList == null)
                    {
                        targetRowList = rowdata;
                    }
                    else if (targetRowList.Value < rowdata.Value)
                    {
                        sameflg       = false;
                        targetRowList = rowdata;
                    }
                    else if (targetRowList.Value == rowdata.Value)
                    {
                        sameflg = true;
                    }
                }
                if (sameflg)
                {
                    rowlist.AnalyzeDatas.Reverse();
                    row++;
                    continue;
                }

                if (targetDataList.Count == targetRowList.Value)
                {
                    //解析済みにする
                    targetRowList.Analyzed();
                    if (targetDataList[0].Col > 0)
                    {
                        if (_bitmapData[targetDataList[0].Row, targetDataList[0].Col - 1].IsValid() == false)
                        {
                            _bitmapData[targetDataList[0].Row, targetDataList[0].Col - 1].Mask();
                        }
                    }
                    if (targetDataList[targetDataList.Count - 1].Col < colNumbers.Count - 1)
                    {
                        if (_bitmapData[targetDataList[targetDataList.Count - 1].Row, targetDataList[targetDataList.Count - 1].Col + 1].IsValid() == false)
                        {
                            _bitmapData[targetDataList[targetDataList.Count - 1].Row, targetDataList[targetDataList.Count - 1].Col + 1].Mask();
                        }
                    }
                }

                rowlist.AnalyzeDatas.Reverse();
                row++;
            }
        }
        private void pattern9Row()
        {
            int row = 0;

            foreach (var rowlist in rowNumbers)
            {
                if (rowlist.IsAnalyzed())
                {
                    row++;
                    continue;
                }

                // 有効な数字で一番大きいものを取り出す
                AnalyzeData aData = null;
                int         count = 0;
                foreach (var v in rowlist.AnalyzeDatas)
                {
                    if (v.IsAnalyzed() == true)
                    {
                        continue;
                    }
                    else
                    {
                        aData = v;
                        count++;
                    }
                    if (count > 1)
                    {
                        break;
                    }
                }
                if (count > 1)
                {
                    row++;
                    continue;
                }
                if (aData == null)
                {
                    row++;
                    continue;
                }
                int value = aData.Value;

                // 対象となるマスを抽出する
                List <List <BitmapData> > bitmapLists = extractTargetBitmapListsCol(row);
                if (bitmapLists.Count != 1)
                {
                    row++;
                    continue;
                }

                // 塗られている場所を特定
                int  leftCol  = colNumbers.Count;
                int  rightCol = 0;
                bool painted  = false;
                foreach (var bitmap in bitmapLists[0])
                {
                    if (bitmap.IsPainted())
                    {
                        if (painted == false)
                        {
                            leftCol = bitmap.Col;
                            painted = true;
                        }
                    }
                    else
                    {
                        if (painted)
                        {
                            rightCol = bitmap.Col;
                            break;
                        }
                    }
                }
                // 左側をマスク
                for (int col = 0; col < rightCol - value; col++)
                {
                    if (_bitmapData[row, col].IsValid() == false)
                    {
                        _bitmapData[row, col].Mask();
                    }
                }

                // 右側をマスク
                for (int col = leftCol + value; col < colNumbers.Count; col++)
                {
                    if (_bitmapData[row, col].IsValid() == false)
                    {
                        _bitmapData[row, col].Mask();
                    }
                }

                row++;
            }
        }
        private void pattern14Col()
        {
            int col = 0;

            foreach (var collist in colNumbers)
            {
                if (collist.IsAnalyzed())
                {
                    col++;
                    continue;
                }

                // 有効な数字を取り出す
                List <AnalyzeData> aData = new List <AnalyzeData>();
                foreach (var data in collist.AnalyzeDatas)
                {
                    if (data.IsAnalyzed())
                    {
                        continue;
                    }
                    aData.Add(data);
                }

                // 対象となるマスを抽出する
                List <List <BitmapData> > bitmapLists = extractTargetBitmapListsRow(col);
                bitmapLists.Reverse();

                // 数字とマスを照合する
                if (bitmapLists.Count != aData.Count)
                {
                    col++;
                    continue;
                }

                AnalyzeData maxData = null;
                int         remi    = 0;
                for (int i = 0; i < aData.Count; i++)
                {
                    if (maxData == null)
                    {
                        maxData = aData[i];
                    }
                    else
                    {
                        if (maxData.Value < aData[i].Value)
                        {
                            remi = i;
                        }
                    }
                }
                if (maxData != null)
                {
                    if (bitmapLists[remi].Count == maxData.Value)
                    {
                        foreach (var b in bitmapLists[remi])
                        {
                            b.Paint();
                        }
                        maxData.Analyzed();
                    }
                }
                col++;
            }
        }
        private void pattern9Col()
        {
            int col = 0;

            foreach (var collist in colNumbers)
            {
                if (collist.IsAnalyzed())
                {
                    col++;
                    continue;
                }

                // 有効な数字で一番大きいものを取り出す
                AnalyzeData aData = null;
                int         count = 0;
                foreach (var v in collist.AnalyzeDatas)
                {
                    if (v.IsAnalyzed() == true)
                    {
                        continue;
                    }
                    else
                    {
                        aData = v;
                        count++;
                    }
                    if (count > 1)
                    {
                        break;
                    }
                }
                if (count > 1)
                {
                    col++;
                    continue;
                }
                if (aData == null)
                {
                    col++;
                    continue;
                }
                int value = aData.Value;

                // 対象となるマスを抽出する
                List <List <BitmapData> > bitmapLists = extractTargetBitmapListsRow(col);
                if (bitmapLists.Count != 1)
                {
                    col++;
                    continue;
                }

                // 塗られている場所を特定
                int  topRow  = rowNumbers.Count;
                int  downRow = 0;
                bool painted = false;
                foreach (var bitmap in bitmapLists[0])
                {
                    if (bitmap.IsPainted())
                    {
                        if (painted == false)
                        {
                            topRow  = bitmap.Row;
                            painted = true;
                        }
                    }
                    else
                    {
                        if (painted)
                        {
                            downRow = bitmap.Row;
                            break;
                        }
                    }
                }
                // 左側をマスク
                for (int row = 0; row < downRow - value; row++)
                {
                    if (_bitmapData[row, col].IsValid() == false)
                    {
                        _bitmapData[row, col].Mask();
                    }
                }

                // 右側をマスク
                for (int row = topRow + value; row < rowNumbers.Count; row++)
                {
                    if (_bitmapData[row, col].IsValid() == false)
                    {
                        _bitmapData[row, col].Mask();
                    }
                }

                col++;
            }
        }