Пример #1
0
        private async Task <PossibleActionsAndCurrentScore> CollectScoreInHand(PossibleActionsAndCurrentScore options)
        {
            while (options.CurrentScoreInHand != 0)
            {
                if (options.CanCollectScoreHere)
                {
                    options = await _client.CollectScore();

                    continue;
                }

                // Looking for known route to collection point
                var stack = FindBestCollectStack(_collectCrumbs, _exitCrumbs);
                if (stack != null)
                {
                    var dir  = stack.Peek();
                    var step = ReverseDir(dir);
                    options = await MakeMove(step, _exitCrumbs, _collectCrumbs, _crawlCrumbs);

                    continue;
                }

                // No known CP. Find the most useful direction to hopefully find one
                var mostUsefulDirection = MostUsefulDirForLocatingCollectionPoint(options, _crawlCrumbs);
                if (mostUsefulDirection != null)
                {
                    options = await MakeMove(mostUsefulDirection.Direction, _exitCrumbs, _collectCrumbs, _crawlCrumbs);

                    continue;
                }

                // Back-track if no new directions were found
                if (_crawlCrumbs.Any())
                {
                    var dir = ReverseDir(_crawlCrumbs.Peek());
                    options = await MakeMove(dir, _exitCrumbs, _collectCrumbs, _crawlCrumbs);

                    continue;
                }

                Console.WriteLine("No possible route to Collection Point!");
            }

            return(options);
        }
Пример #2
0
 public async Task <PossibleActionsAndCurrentScore> CollectScore()
 {
     IncreaseInvocationCount();
     return(await _amazeingClientImplementation.CollectScore());
 }