Ejemplo n.º 1
0
        public void Run()
        {
            try {
                remoteProcessClient.WriteTokenMessage(token);
                remoteProcessClient.WriteProtocolVersionMessage();
                remoteProcessClient.ReadTeamSizeMessage();
                Game game = remoteProcessClient.ReadGameContextMessage();

                IStrategy strategy = new MyStrategy();

                PlayerContext playerContext;

                while ((playerContext = remoteProcessClient.ReadPlayerContextMessage()) != null)
                {
                    Player player = playerContext.Player;
                    if (player == null)
                    {
                        break;
                    }

                    Move move = new Move();
                    strategy.Move(player, playerContext.World, game, move);

                    remoteProcessClient.WriteMoveMessage(move);
                }
            } finally {
                remoteProcessClient.Close();
            }
        }
Ejemplo n.º 2
0
        public void DoFacilities()
        {
            if (Facilities.Length == 0)
            {
                return;
            }

            Logger.CumulativeOperationStart("DoFacilities");
            foreach (var veh in Vehicles)
            {
                if (!veh.CanChargeFacility)
                {
                    continue;
                }
                if (!veh.IsMy) // HACK: из-за неоднозначного порядка захвата лучше вообще не моделировать действие соперника
                {
                    continue;
                }

                var facilityIdx = MyStrategy.FacilityIndex(veh.X, veh.Y);
                if (facilityIdx != -1)
                {
                    Facilities[facilityIdx].Charge(veh);
                }
            }
            Logger.CumulativeOperationEnd("DoFacilities");
        }
Ejemplo n.º 3
0
        public MyUnitWithDelayedTask(MyStrategy strategy, int group, Action delayedAction, int abortAfter)
        {
            _abortAfter = abortAfter;
            _strategy   = strategy;
            _groupId    = group;
            _strategy.UnitsForAdd.Add(this);
            _startTick = _strategy.World.TickIndex;

            _delayedAction = delayedAction;
        }
Ejemplo n.º 4
0
        public MyGameGrid(MyStrategy strategy)
        {
            _strategy = strategy;

            _cellCount = Convert.ToInt32(strategy.World.Width) / GameGridDelta;

            Grid = new MyGridCellInfo[_cellCount, _cellCount];

            for (var i = 0; i < _cellCount; i++)
            {
                for (var j = 0; j < _cellCount; j++)
                {
                    Grid[i, j] = new MyGridCellInfo(i, j);
                }
            }
        }
Ejemplo n.º 5
0
        public MyUnitWithDelayedTask(MyStrategy strategy, Group group, Queue <Task <bool> > delayedTask, int abortAfter)
        {
            _abortAfter = abortAfter;
            _strategy   = strategy;
            _groupId    = (int)group;
            _strategy.UnitsForAdd.Add(this);
            _startTick = _strategy.World.TickIndex;

            _delayedTask   = delayedTask;
            _delayedAction = () =>
            {
                while (_delayedTask.Any())
                {
                    var task = _delayedTask.Dequeue();
                    _strategy.MainGameTasks.Enqueue(task);
                }
            };
        }
Ejemplo n.º 6
0
        public void Run()
        {
            try {
                remoteProcessClient.WriteTokenMessage(token);
                remoteProcessClient.WriteProtocolVersionMessage();
                remoteProcessClient.ReadTeamSizeMessage();
                Game game = remoteProcessClient.ReadGameContextMessage();

                IStrategy strategy = new MyStrategy();

                PlayerContext playerContext;

                try
                {
                    while ((playerContext = remoteProcessClient.ReadPlayerContextMessage()) != null)
                    {
                        Player player = playerContext.Player;
                        if (player == null)
                        {
                            break;
                        }

                        Move move = new Move();
                        strategy.Move(player, playerContext.World, game, move);

                        remoteProcessClient.WriteMoveMessage(move);
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Ошибка... Выход через 3 сек");
                    System.Console.WriteLine(ex);
                    System.Threading.Thread.Sleep(3000);
                }
            } finally {
                remoteProcessClient.Close();
            }
        }
Ejemplo n.º 7
0
 public MyDelayTaksBuilder(MyStrategy strategy)
 {
     _strategy = strategy;
 }
Ejemplo n.º 8
0
 public MyFirstRoundGroupMaker(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 9
0
 public MyGroupManager(MyStrategy myStrategy)
 {
     _str  = myStrategy;
     _grid = myStrategy.GameGrid.Grid;
 }
Ejemplo n.º 10
0
 public MyFirstRoundController(MyStrategy str)
 {
     _str = str;
 }
Ejemplo n.º 11
0
 public MyEnemyStrategyRecognizer(MyStrategy strategy)
 {
     _strategy = strategy;
 }
Ejemplo n.º 12
0
 public MyIndicatorFacilites(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 13
0
 public MyFirstRoundNuckearEvader(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 14
0
 public MyActionMaker(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 15
0
 public MySecondRoundController(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 16
0
 public MySecondRoundGroupMaker(MyStrategy strategy)
 {
     _str = strategy;
 }
Ejemplo n.º 17
0
 public MySecondRoundNuclearEvader(MyStrategy strategy)
 {
     _str = strategy;
 }