示例#1
0
        /// <summary>
        /// Find all words in the sub-tree from here
        /// </summary>
        /// <param name="node">The node in the LetterGrid that should align with this node in the dictionary tree</param>
        /// <param name="allowMultiWords">Allow matches which are made up of multiple words</param>
        /// <param name="soln">A partial solution to start with</param>
        public void FindAllWords(GridNode node, bool allowMultiWords, Solutions.PartialSoln soln = null)
        {
            node.Use();

            if (_isWord)
            {
                if (allowMultiWords)
                {
                    if (!node.ParentGrid.CheckForMandatoryNodes())
                    {
                        if (soln == null)
                        {
                            soln = new Solutions.PartialSoln();
                        }
                        this.Root.FindAllWords(node, true, new Solutions.PartialSoln(soln, this.ToString()));
                    }
                    else
                    {
                        if (soln == null)
                        {
                            Solutions.AddWord(this.ToString());
                        }
                        else
                        {
                            Solutions.AddWord(new Solutions.PartialSoln(soln, this.ToString()));
                        }
                    }
                }
                else if (_depth >= (Properties.Settings.Default.MinWordLength - 1) && node.IsUsed && node.ParentGrid.CheckForMandatoryNodes())
                {
                    Solutions.AddWord(this.ToString());
                }
            }

            foreach (GridNode n in node.GetAdjacentNodes())
            {
                if (!n.IsUsed)
                {
                    foreach (DictNode n2 in Children)
                    {
                        if (n.GetLetter() == n2.LetterEnum)
                        {
                            n2.FindAllWords(n, allowMultiWords, new Solutions.PartialSoln(soln));
                            n.Release();
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Find all the words in the dictionary given a starting node in the LetterGrid and a partially completed solution.
 /// i.e. this method is used for adding on to an already found word
 /// </summary>
 /// <param name="node">The node in the LetterGrid to start with</param>
 /// <param name="allowMultiWords">True to allow matches made up of multiple words</param>
 /// <param name="soln">The partial solution to add to</param>
 public void FindAllWords(GridNode node, bool allowMultiWords, Solutions.PartialSoln soln)
 {
     foreach (GridNode n in node.GetAdjacentNodes())
     {
         if (!n.IsUsed)
         {
             foreach (DictNode n2 in Children)
             {
                 if (n.GetLetter() == n2.LetterEnum)
                 {
                     n2.FindAllWords(n, allowMultiWords, new Solutions.PartialSoln(soln));
                     n.Release();
                     break;
                 }
             }
         }
     }
 }