예제 #1
0
        private BoggleResult CreateResult(BoggleTracker tracker)
        {
            BoggleResult result = new BoggleResult(tracker.Board, tracker.WordPointDict,
                                                   tracker.Points, tracker.Stopwatch.Elapsed);

            return(result);
        }
예제 #2
0
        public BoggleResult Play(IBogglePlayer player, int randomSeed = 0, int boardSize = BoggleRules.BoardSizeDefault)
        {
            BoggleBoard   board   = Rules.GenerateBoard(randomSeed, boardSize);
            BoggleTracker tracker = CreateTracker(player, board);

            tracker.Start();

            try
            {
                player.Solve(board);
                tracker.Stop();
            }
            catch (Exception)
            {
                tracker.Stop();
                tracker.Update(string.Empty, BoggleRules.CatastrophicScore);
                throw;
            }

            BoggleResult result = CreateResult(tracker);

            DeleteTracker(player.Id, board.Id);
            return(result);
        }