Пример #1
0
 private void GenerateNewGrid(object state)
 {
     LoadDictionary(HttpRuntime.AppDomainAppPath + "/" + System.Configuration.ConfigurationManager.AppSettings["DictionaryPath"] + "/Dictionary.txt");
     //if (Application["CurrentGrid"] == null)
     Application["CurrentGrid"] = new Grid();
     Task.Factory.StartNew(new Action(SolveGrid));
 }
Пример #2
0
 private void GenerateNewGrid(object state)
 {
     var curGrid = lst[servedGridIndex++];
     LatestServedTime = DateTime.Now.AddSeconds(30);
     UniversalGameStatus = new GameStatus(GameStatusEnum.SCOREDISPLAY, 30);
     gameStatusTimer.Start();
     Application["CurrentGrid"] = CurrentGrid = curGrid.Grid;
     Application["CurrentGridSolution"] = CurrentGridSolution = servedGridIndex > 1 ? lst[servedGridIndex - 2].Solution : null;// distribute results of the previous grid
     Broadcaster.DisableGamePlay = true;
     CurrentServedObject = new ServedObject { Status = MvcApplication.UniversalGameStatus, Solution = MvcApplication.CurrentGridSolution };
     GlobalHost.ConnectionManager.GetHubContext<MoveShapeHub>().Clients.All.DisableGamePlay(CurrentServedObject);
     curGrid.Grid.ServedOn = LatestServedTime;
     if ((lst.Count() - servedGridIndex) < 10)
         Task.Factory.StartNew(new Action(AddNewGrids));
 }
Пример #3
0
 static CurrentGrid()
 {
     g = new Grid();
 }
Пример #4
0
 private void Solve(Grid grid)
 {
     this.foundWords.Clear();
     alphaList = grid.Tiles;
     List<string> foundWords = new List<string>();
     var dict = DictionaryProvider.AllWords;
     for (int i = 0; i < 16; i++)
     {
         // start with every word
         var curTile = alphaList[i];
         var subDict = dict.Where(d => d.StartsWith(curTile.Letter)).ToList();
         if (subDict.Count == 0)
         {
             // no words found, break the loop and continue with next letter in the alphabet
             continue;
         }
         else // iterate recursively to look for words
         {
             foreach (var x in ConnectedGrids[curTile.Order].Select(k => alphaList[k.Index()]))
                 IsValidWord(curTile.Letter, x, subDict);
         }
     }
 }
Пример #5
0
 public GridSolution()
 {
     Grid = new Grid();
     SolveGrid();
     foundWords = foundWords.Distinct().ToList();
     Solution = foundWords;
 }