public IEnumerable<Point> Play(GameContext context) { var myDrones = context.GetDronesOfTeam(this.TeamId); // here I always ask my drones to reach the bottom right corner... stupid :-) foreach(var drone in myDrones) { yield return new Point(GameContext.FieldWidth - 1, GameContext.FieldHeight - 1); } }
public IEnumerable<Point> Play(GameContext context) { // write input foreach(var zone in context.Zones) _playerInput.WriteLine("{0}", zone.OwnerId); foreach(var team in context.Teams) foreach(var drone in team.Drones) _playerInput.WriteLine("{0} {1}", drone.Position.X, drone.Position.Y); // get output foreach(var drone in context.GetDronesOfTeam(this.TeamId)) { // ReSharper disable once PossibleNullReferenceException var xy = _playerOutput.ReadLine().Split(' ').Select(int.Parse).ToArray(); yield return new Point { X = xy[0], Y = xy[1] }; } }
public void Initialize(GameContext context) { var errorlog = Console.Error; var dummyLog = new StreamWriter(Stream.Null); _droneActivityObserver = new BasicDroneActivityObserver(dummyLog); _zoneEvaluator = new BasicZoneEvaluator(dummyLog); _taskOrganizer = new OneTaskPerZoneOrganizer(dummyLog); _droneAllocator = (context.Teams.Count > 2 ? (IDroneAllocator)new FocusedDroneAllocator(dummyLog) : (IDroneAllocator)new PriorityBasedDroneAllocator(dummyLog)); _droneCommander = new BasicDroneCommander(dummyLog); _contextInfo = new ContextInfo(this.TeamId, context); _contextInfo.Zones = context.Zones.Select(z => new ZoneInfo(z)).ToArray(); _contextInfo.MyDrones = context.GetDronesOfTeam(this.TeamId).Select(d => new MyDroneInfo(d)).ToArray(); _contextInfo.EnemyDrones = context.GetDronesOfOtherTeams(this.TeamId).Select(d => new EnemyDroneInfo(d)).ToArray(); _zoneEvaluator.GiveInitialZoneEvaluations(_contextInfo.Zones); }