コード例 #1
0
ファイル: Form1.cs プロジェクト: mcnorth/Crozzle-Project
        private CrozzleGrid Recursive(CrozzleGrid aGrid, WordListTaskTwo wordList)
        {
            while (aTimer.Enabled == true)
            {
                if (aGrid.GetWordlistCount() == 0)
                {
                    return(aGrid);
                }
                if (aGrid.GetRootWord() == "")
                {
                    aGrid.AddRootWord();
                    aGrid.AddWordToGrid();
                }
                else
                {
                    aGrid.AddWordToGrid();
                }
                if (aGrid.GetCounter() == 0)
                {
                    ListOfGrids.Add(aGrid); //not copying the obj, everytime it adds a new grid it overides the reference in the list
                    WordListTaskTwo freshWordlist = new WordListTaskTwo(wordList);
                    CrozzleGrid     bGrid         = new CrozzleGrid(aGrid, freshWordlist);

                    return(Recursive(bGrid, freshWordlist));
                }

                return(Recursive(aGrid, wordList));
            }

            return(aGrid);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: mcnorth/Crozzle-Project
        private void OpenCrozzleAss2()
        {
            aTimer.Enabled = true;



            CrozzleTaskTwo config = new CrozzleTaskTwo(URLs.Task2Crozzle);
            // string configurationFileName = GetConfigurationFileName(URLs.Task2Crozzle);

            //validate configuration file.
            Configuration aConfiguration = null;

            Configuration.TryParseTaskTwo(config.ConfigurationURL, out aConfiguration);

            // Parse wordlist file.
            WordListTaskTwo wordList = new WordListTaskTwo(config.WordlistURL);

            //WordList.TryParseTaskTwo(config.WordlistURL, aConfiguration, out wordList);

            //char[,] grid = new char[Convert.ToInt16(config.Rows), Convert.ToInt16(config.Columns)];

            CrozzleGrid aGrid = new CrozzleGrid(aConfiguration, wordList, config);

            aGrid.AddRootWord();
            //aGrid.AddFirstWord();

            //Tree aTree = new Tree(aGrid);
            //aGrid.AddNameToGrid();

            //while (aTimer.Enabled = true || aGrid.GetWordlistCount() > 0)
            //{

            //}

            Recursive(aGrid, wordList);


            //aGrid.AddWordToGrid();
            //aTree.Add(aGrid);
            //aGrid.AddWordToGrid();
            //aGrid.AddWordToGrid();
            //aGrid.AddWordToGrid();
            //aGrid.AddWordToGrid();



            //ListOfGrids.Sort((x, y) => x.Score.CompareTo(y.OrderDate));

            //ListOfGrids.Sort()


            var maxObject = ListOfGrids.OrderByDescending(item => item.Score).First();

            string res = aGrid.DisplayGrid(maxObject);

            //string res = aGrid.CreateGrid();

            crozzleWebBrowser.DocumentText = res;

            //string res = aGrid.DisplayGrid(aGrid);
            ////string res = aGrid.CreateGrid();

            //crozzleWebBrowser.DocumentText = res;
        }