Esempio n. 1
0
        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 void Initialize(GameContext context)
        {
            _playerProcess.Start();
            _playerInput = _playerProcess.StandardInput;
            _playerOutput = _playerProcess.StandardOutput;

            _playerInput.WriteLine("{0} {1} {2} {3}",
                context.Teams.Count, this.TeamId, context.Teams[0].Drones.Count, context.Zones.Count);

            foreach(var zone in context.Zones)
                _playerInput.WriteLine("{0} {1}", zone.Center.X, zone.Center.Y);
        }
        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] };
            }
        }
Esempio n. 4
0
 public void Initialize(GameContext context)
 {
 }
Esempio n. 5
0
        public IEnumerable<Point> Play(GameContext context)
        {
            _droneActivityObserver.GuessEnemyDronesActivity(_contextInfo);

            _zoneEvaluator.UpdateZoneEvaluations(_contextInfo);

            var tasks = _taskOrganizer.DefineTasks(_contextInfo);

            _droneAllocator.AllocateDronesToTasks(_contextInfo, tasks);

            _droneCommander.SetDroneDestinations(_contextInfo);

            return _contextInfo.MyDrones.Select(d => d.Destination);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public ContextInfo(int myTeamId, GameContext context)
 {
     this.MyTeamId = myTeamId;
     this.Context = context;
 }