예제 #1
0
 private static async Task DoTheKonami(IAmazeingClient mazeClient)
 {
     try{ await mazeClient.Move(Direction.Up); } catch { }
     try{ await mazeClient.Move(Direction.Up); } catch { }
     try{ await mazeClient.Move(Direction.Down); } catch { }
     try{ await mazeClient.Move(Direction.Down); } catch { }
     try{ await mazeClient.Move(Direction.Left); } catch { }
     try{ await mazeClient.Move(Direction.Right); } catch { }
     try{ await mazeClient.Move(Direction.Left); } catch { }
     try{ await mazeClient.Move(Direction.Right); } catch { }
 }
예제 #2
0
        private async Task <PossibleActionsAndCurrentScore> MakeMove(Direction direction,
                                                                     List <Stack <Direction> > exitCrumbs, List <Stack <Direction> > collectCrumbs,
                                                                     Stack <Direction> crumbs)
        {
            try
            {
                var newOptions = await _client.Move(direction);

                if (newOptions == null)
                {
                    throw new ArgumentException();
                }

                // Record the move in all crumbs
                foreach (var st in exitCrumbs)
                {
                    Push(st, direction);
                }

                foreach (var st in collectCrumbs)
                {
                    Push(st, direction);
                }

                Push(crumbs, direction);

                // Check for nearby exits and collectionPoints
                TrackExits(newOptions, _exitCrumbs);
                TrackCollectionPoints(newOptions, _collectCrumbs);

                return(newOptions);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
예제 #3
0
 public async Task <PossibleActionsAndCurrentScore> Move(Direction direction)
 {
     IncreaseInvocationCount();
     return(await _amazeingClientImplementation.Move(direction));
 }