Beispiel #1
0
        public void run()
        {
            try
            {
                remoteProcessClient.WriteToken(token);
                int teamSize = remoteProcessClient.ReadTeamSize();
                remoteProcessClient.WriteProtocolVersion();
                Game game = remoteProcessClient.readGameContext();

                IStrategy[] strategies = new IStrategy[teamSize];

                for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
                {
                    strategies[strategyIndex] = new MyStrategy();
                }

                PlayerContext playerContext;

                while ((playerContext = remoteProcessClient.ReadPlayerContext()) != null)
                {
                    Trooper playerTrooper = playerContext.Trooper;

                    Move move = new Move();
                    strategies[playerTrooper.TeammateIndex].Move(playerTrooper, playerContext.World, game, move);
                    remoteProcessClient.WriteMove(move);
                }
            }
            finally
            {
                remoteProcessClient.Close();
            }
        }
Beispiel #2
0
        public void run()
        {
            try
            {
                remoteProcessClient.WriteToken(token);
                int teamSize = remoteProcessClient.ReadTeamSize();
                remoteProcessClient.WriteProtocolVersion();
                Game game = remoteProcessClient.readGameContext();

                IStrategy[] strategies = new IStrategy[teamSize];

                for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
                {
                    strategies[strategyIndex] = new MyStrategy();
                }

                PlayerContext playerContext;

                while ((playerContext = remoteProcessClient.ReadPlayerContext()) != null)
                {
                    Trooper playerTrooper = playerContext.Trooper;

                    Move move = new Move();
                    strategies[playerTrooper.TeammateIndex].Move(playerTrooper, playerContext.World, game, move);
                    remoteProcessClient.WriteMove(move);
                }
            }
            finally
            {
                remoteProcessClient.Close();
            }
        }
Beispiel #3
0
        public static double GetAngleBetween(Point a, Point b, Point c)
        {
            var ac  = a.GetDistanceTo(c);
            var ab  = a.GetDistanceTo(b);
            var bc  = b.GetDistanceTo(c);
            var arg = -(ac * ac - ab * ab - bc * bc) / 2 / ab / bc;

            if (arg < -1)
            {
                arg = -1;
            }
            if (arg > 1)
            {
                arg = 1;
            }
            return(MyStrategy.AngleNormalize(Math.Acos(arg)));
        }