示例#1
0
        public void Validate()
        {
            CrozzleGridErrors = new List <String>();

            // Indicate that validity has been attempted.
            ValidityChecked = true;

            // Get all sequences of 2 or more letters.
            CrozzleSequences = new CrozzleSequences(CrozzleRows, CrozzleColumns, Configuration);

            // Check that the number of rows is within limits.
            if (Rows < Configuration.MinimumNumberOfRows || Rows > Configuration.MaximumNumberOfRows)
            {
                CrozzleGridErrors.Add(String.Format(CrozzleFileErrors.RowCountError, Rows, Configuration.MinimumNumberOfRows, Configuration.MaximumNumberOfRows));
            }

            // Check that the number of columns is within limits.
            if (Columns < Configuration.MinimumNumberOfColumns || Columns > Configuration.MaximumNumberOfColumns)
            {
                CrozzleGridErrors.Add(String.Format(CrozzleFileErrors.ColumnCountError, Columns, Configuration.MinimumNumberOfColumns, Configuration.MaximumNumberOfColumns));
            }

            // Check that the number of words is within limits.
            // Check that the number of horizontal words is within limits.
            if (Node.Grid.HorizontalWordDataList.Count < Configuration.MinimumHorizontalWords || Node.Grid.HorizontalWordDataList.Count > Configuration.MaximumHorizontalWords)
            {
                CrozzleGridErrors.Add(String.Format(CrozzleErrors.HorizontalWordCountError, Node.Grid.HorizontalWordDataList.Count, Configuration.MinimumHorizontalWords, Configuration.MaximumHorizontalWords));
            }

            // Check that the number of vertical words is within limits.
            if (Node.Grid.VerticalWordDataList.Count < Configuration.MinimumVerticalWords || Node.Grid.VerticalWordDataList.Count > Configuration.MaximumVerticalWords)
            {
                CrozzleGridErrors.Add(String.Format(CrozzleErrors.VerticalWordCountError, Node.Grid.VerticalWordDataList.Count, Configuration.MinimumVerticalWords, Configuration.MaximumVerticalWords));
            }

            // Check that the number of vertical words that intersect a horizontal word is within limits.
            CrozzleSequences.CheckHorizontalIntersections(Configuration.MinimumIntersectionsInHorizontalWords, Configuration.MaximumIntersectionsInHorizontalWords);

            // Check that the number of horizontal words that intersect a vertical word is within limits.
            CrozzleSequences.CheckVerticalIntersections(Configuration.MinimumIntersectionsInVerticalWords, Configuration.MaximumIntersectionsInVerticalWords);

            // Check that the number of duplicate words is within limits.
            CrozzleSequences.CheckDuplicateWords(Configuration.MinimumNumberOfTheSameWord, Configuration.MaximumNumberOfTheSameWord);

            // Check that the number of groups of connected words is within the limit.
            CrozzleSequences.CheckConnectivity(Configuration.MinimumNumberOfGroups, Configuration.MaximumNumberOfGroups, CrozzleRows, CrozzleColumns);

            // Check that each sequence is in the wordlist.
            CrozzleSequences.FindMissingWords(WordList);

            // Is this crozzle valid?
            CrozzleValid = true;
            if (CrozzleSequences.ErrorsDetected)
            {
                CrozzleValid = false;
                CrozzleGridErrors.AddRange(CrozzleSequences.ErrorMessages);
            }
        }
示例#2
0
        /// <summary>
        /// Validate each generated crozzle
        /// </summary>
        /// <param name="testGrid"></param>
        public bool Validate(Grid testGrid)
        {
            CrozzleRows    = new List <String[]>();
            CrozzleColumns = new List <String[]>();

            // Get all row data
            for (int r = 0; r < CrozzleRow; r++)
            {
                String[] row = new String[CrozzleColumn];
                for (int c = 0; c < row.Length; c++)
                {
                    row[c] = testGrid.GridCoordinate[r, c].ToString();
                }
                CrozzleRows.Add(row);
            }

            // Get all column data
            for (int c = 0; c < CrozzleColumn; c++)
            {
                String[] col = new String[CrozzleRow];
                for (int r = 0; r < col.Length; r++)
                {
                    col[r] = testGrid.GridCoordinate[r, c].ToString();
                }
                CrozzleColumns.Add(col);
            }

            CrozzleSequences = new CrozzleSequences(CrozzleRows, CrozzleColumns, Configuration);

            // Check that the number of rows is within limits.
            if (CrozzleRow < Configuration.MinimumNumberOfRows || CrozzleRow > Configuration.MaximumNumberOfRows)
            {
                //CrozzleGridErrors.Add(String.Format(CrozzleFileErrors.RowCountError, Rows, Configuration.MinimumNumberOfRows, Configuration.MaximumNumberOfRows));
                return(false);
            }
            // Check that the number of columns is within limits.
            if (CrozzleColumn < Configuration.MinimumNumberOfColumns || CrozzleColumn > Configuration.MaximumNumberOfColumns)
            {
                //CrozzleGridErrors.Add(String.Format(CrozzleFileErrors.ColumnCountError, Columns, Configuration.MinimumNumberOfColumns, Configuration.MaximumNumberOfColumns));
                return(false);
            }
            // Check that the number of vertical words that intersect a horizontal word is within limits.
            CrozzleSequences.CheckHorizontalIntersections(Configuration.MinimumIntersectionsInHorizontalWords, Configuration.MaximumIntersectionsInHorizontalWords);

            // Check that the number of horizontal words that intersect a vertical word is within limits.
            CrozzleSequences.CheckVerticalIntersections(Configuration.MinimumIntersectionsInVerticalWords, Configuration.MaximumIntersectionsInVerticalWords);

            // Check that the number of duplicate words is within limits.
            CrozzleSequences.CheckDuplicateWords(Configuration.MinimumNumberOfTheSameWord, Configuration.MaximumNumberOfTheSameWord);

            // Check that the number of groups of connected words is within the limit.
            CrozzleSequences.CheckConnectivity(Configuration.MinimumNumberOfGroups, Configuration.MaximumNumberOfGroups, CrozzleRows, CrozzleColumns);

            if (CrozzleSequences.ErrorsDetected)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }