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(); } }
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))); }