示例#1
0
        public new void ProcessMessage(EntityMessage message)
        {
            if (message.arg1 == 1)
            {
                isAlly  = true;
                isEnemy = false;

                team  = Team.Ally;
                start = Factory.GetFactoryByID(message.arg2);
                end   = Factory.GetFactoryByID(message.arg3);

                turns   = message.arg4;
                endTime = Game.gameTime + turns;

                end.incoming.Add(this);
            }
            else
            {
                isAlly  = false;
                isEnemy = true;

                turns   = 0;
                endTime = Game.gameTime;

                team = Team.Enemy;

                enemyBombs.Add(id, this);

                start = Factory.GetFactoryByID(message.arg2);

                if (Game.gameTime == 1)
                {
                    end     = Factory.ally.First();
                    turns   = end.links[start];
                    endTime = Game.gameTime + turns;

                    oldBombs.Add(this);
                }
            }

            start = Factory.GetFactoryByID(message.arg2);
            //DeduceBomb();
        }
示例#2
0
        static void Main(string[] args)
        {
            string[] inputs;
            int      factoryCount = int.Parse(Console.ReadLine()); // the number of factories
            int      linkCount    = int.Parse(Console.ReadLine()); // the number of links between factories

            for (int i = 0; i < linkCount; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                int factory1 = int.Parse(inputs[0]);
                int factory2 = int.Parse(inputs[1]);
                int distance = int.Parse(inputs[2]);

                Factory.AddLink(factory1, factory2, distance);
            }

            Game.InitializeFirstTurn();

            // game loop
            while (true)
            {
                float loopStartTime = Timer.TickCount;

                int entityCount = int.Parse(Console.ReadLine()); // the number of entities (e.g. factories and troops)
                for (int i = 0; i < entityCount; i++)
                {
                    var str = Console.ReadLine();

                    EntityMessage message = new EntityMessage(str);
                    message.ProcessMessage();
                }

                Game.InitializeTurn();
                Game.MakeMove();
                Game.PrintActions(); //Print the move
                Game.CleanUp();

                float loopTime = Timer.TickCount - loopStartTime;
                Console.Error.WriteLine("LoopTime: " + loopTime);
            }
        }
示例#3
0
        public new void ProcessMessage(EntityMessage message)
        {
            if (message.arg1 == 1)
            {
                isAlly  = true;
                isEnemy = false;

                team  = Team.Ally;
                start = Factory.GetFactoryByID(message.arg2);
                end   = Factory.GetFactoryByID(message.arg3);

                turns   = message.arg4;
                endTime = Game.gameTime + turns;

                end.incoming.Add(this);
                AddMockBombTroop();
            }
            else
            {
                isAlly  = false;
                isEnemy = true;

                turns   = 0;
                endTime = Game.gameTime;

                team = Team.Enemy;

                enemyBombs.Add(id, this);

                start = Factory.GetFactoryByID(message.arg2);

                this.DeduceBomb();
            }

            start = Factory.GetFactoryByID(message.arg2);
        }
示例#4
0
        public void ProcessMessage(EntityMessage message)
        {
            if (message.arg1 == 1)
            {
                SetTeam(Team.Ally);
            }
            else
            {
                SetTeam(Team.Enemy);
            }

            start   = Factory.GetFactoryByID(message.arg2);
            end     = Factory.GetFactoryByID(message.arg3);
            count   = message.arg4;
            turns   = message.arg5;
            endTime = Game.gameTime + turns;

            inTransit = true;

            end.incoming.Add(this);
            //hashTroops.Add(this.GetStringKey(), this);

            lastEndTime = Math.Max(lastEndTime, endTime); //get the last troop endTime;
        }