예제 #1
0
        /// <summary>
        /// Randomize/reset all crosses
        /// </summary>
        public void Shuffle()
        {
            Items.Clear();
            HorizontalSequences.Clear();
            VerticalSequences.Clear();

            int probability = settings.GetCrossProbability();

            for (int i = 0; i < settings.Rows; i++)
            {
                IList <Item> row = new List <Item>();

                for (int j = 0; j < settings.Columns; j++)
                {
                    bool crossed = random.Next(101) < probability;

                    row.Add(new Item(i, j, crossed));
                }

                Items.Add(row);
                HorizontalSequences.Add(new Sequence(row));
            }

            for (int i = 0; i < settings.Columns; i++)
            {
                VerticalSequences.Add(new Sequence(Items.Column(i)));
            }
        }
예제 #2
0
        private void AddVerticalSequences(List <String[]> crozzleColumns)
        {
            int    columnNumber = 0;
            int    rowIndex;
            String column;

            foreach (String[] crozzleColumn in crozzleColumns)
            {
                columnNumber++;
                rowIndex = 0;

                // Place all letters into one string, so that we can split it later.
                column = "";
                foreach (String letter in crozzleColumn)
                {
                    column = column + letter;
                }

                // Use split to collect all sequences of letters.
                String[] letterSequences = column.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                // Collect and store data about each letter sequence of length > 1, as a sequence of one letter is not a word.
                foreach (String sequence in letterSequences)
                {
                    if (sequence.Length > 1)
                    {
                        // Set row values.
                        int rowNumber = column.IndexOf(sequence, rowIndex) + 1;

                        ////////// Check that duplicate words are within limits.
                        ////////List<WordData> duplicates = Sequences.FindAll(x => x.Letters.Equals(sequence));
                        ////////if (duplicates.Count < Configuration.MinimumNumberOfTheSameWord)
                        ////////    ErrorMessages.Add("\"" + sequence + "\" at (" + rowNumber + ", " + columnNumber + ") exists in the crozzle " + duplicates.Count +
                        ////////        " times, which is more than the limit of " + Configuration.MinimumNumberOfTheSameWord);
                        ////////if (duplicates.Count > Configuration.MaximumNumberOfTheSameWord)
                        ////////    ErrorMessages.Add("\"" + sequence + "\" at (" + rowNumber + ", " + columnNumber + ") exists in the crozzle " + duplicates.Count +
                        ////////        " times, which is more than the limit of " + Configuration.MaximumNumberOfTheSameWord);

                        // Collect data about the word, and
                        // update the index for the next substring search.
                        WordData word = new WordData(WordData.OrientationColumn, rowNumber, columnNumber, sequence);
                        rowIndex = word.Location.Row - 1 + sequence.Length;

                        // Store data about the word.
                        Sequences.Add(word);
                        VerticalSequences.Add(word);
                    }
                }
            }
        }
        private void AddVerticalSequences(List <String[]> crozzleColumns)
        {
            int    columnNumber = 0;
            int    rowIndex;
            String column;

            foreach (String[] crozzleColumn in crozzleColumns)
            {
                columnNumber++;
                rowIndex = 0;

                // Place all letters into one string, so that we can split it later.
                column = "";
                foreach (String letter in crozzleColumn)
                {
                    column = column + letter;
                }

                // Use split to collect all sequences of letters.
                String[] letterSequences = column.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                // Collect and store data about each letter sequence of length > 1, as a sequence of one letter is not a word.
                foreach (String sequence in letterSequences)
                {
                    if (sequence.Length > 1)
                    {
                        // Set row values.
                        int rowNumber = column.IndexOf(sequence, rowIndex) + 1;

                        // Collect data about the word, and
                        // update the index for the next substring search.
                        WordData word = new WordData(WordData.OrientationColumn, rowNumber, columnNumber, sequence);
                        rowIndex = word.Location.Row - 1 + sequence.Length;

                        // Store data about the word.
                        Sequences.Add(word);
                        VerticalSequences.Add(word);
                    }
                }
            }
        }