private static List <Move> PredictEnemyMoves(Pod[] pods, int count) { Pod runner = null; Pod blocker = null; Solution.WhoRunnerBlocker(pods[2], pods[3], out runner, out blocker); runner = runner.Clone(); blocker = blocker.Clone(); List <Move> enemyMoves = new List <Move>(); for (int i = 0; i < count; i++) { Move action1 = runner.GetRunnerAction(); Move action2 = blocker.GetBlockerAction(); if (runner == pods[2]) { enemyMoves.Add(action1); enemyMoves.Add(action2); } else { enemyMoves.Add(action2); enemyMoves.Add(action1); } runner.Rotate(action1.Target(runner)); runner.Thrust(action1.Thrust); blocker.Rotate(action2.Target(blocker)); blocker.Thrust(action2.Thrust); Collision data = GameUnit.CollisionData(runner, blocker); if (data != null) { data.Bounce(); } runner.Move(); blocker.Move(); } return(enemyMoves); }
public Vector Target(Pod pod) { return(Vector.CreateVectorAngleSizeRad(Rotation + pod.AngleRad, 1000)); }
public static double BlokkerScore(Pod blokkerPod) { return(0.0); }
public static double RunnerScore(Pod runnnerpod) { return(runnnerpod.CheckPointNr * 16000 - (Player.raceInfo.Checkpoints[runnnerpod.NextCheckPointId].Position - runnnerpod.Position).Size); }
static void Run() #endif { DateTime nu = DateTime.Now; raceInfo = new RaceInfo(); Pod[] podsInfo = new Pod[4]; podsInfo[0] = new Pod(); podsInfo[1] = new Pod(); podsInfo[2] = new Pod(); podsInfo[3] = new Pod(); UpdatePods(podsInfo); List <Move> enemyMoves = PredictEnemyMoves(podsInfo, 6); List <Solution> Solutions = new List <Solution>(); for (int i = 0; i < 100; i++) { Solutions.Add(new Solution(enemyMoves, true)); } while ((DateTime.Now - nu).Milliseconds < 100) { Solutions = MutateAndCrossSolutions(Solutions, 10); RunSimulations(Solutions, podsInfo); Solutions = SelectSolutions(Solutions, 5); } while (true) { nu = DateTime.Now; Vector t0 = raceInfo.Checkpoints[podsInfo[0].NextCheckPointId].Position - podsInfo[0].Velocity; Vector t1 = raceInfo.Checkpoints[podsInfo[1].NextCheckPointId].Position - podsInfo[1].Velocity; Console.Error.WriteLine(podsInfo[0]); Console.Error.WriteLine(podsInfo[1]); Console.Error.WriteLine(podsInfo[2]); Console.Error.WriteLine(podsInfo[3]); int teller = 0; while ((DateTime.Now - nu).Milliseconds < 90) { Solutions = MutateAndCrossSolutions(Solutions, 10); RunSimulations(Solutions, podsInfo); Solutions = SelectSolutions(Solutions, 5); teller++; } Console.Error.WriteLine(teller); foreach (Solution s in Solutions) { Console.Error.WriteLine(s.Score); } Solution usedSolution = Solutions.First(); // Vector t1 = podsInfo[0].Position + usedSolution.Moves[0].Target(podsInfo[0]); // Console.WriteLine("{0} {1} {2}", (int)t1.X, (int)t1.Y, usedSolution.Moves[0].Thrust); // Vector t2 = podsInfo[1].Position + usedSolution.Moves[1].Target(podsInfo[1]); // Console.WriteLine("{0} {1} {2}", (int)t2.X, (int)t2.Y, usedSolution.Moves[1].Thrust); Console.WriteLine("{0} {1} {2}", t0.X, t0.Y, 100); Console.WriteLine("{0} {1} {2}", t1.X, t1.Y, 100); // simulate oponent // simulate me //} while ((DateTime.Now -nu).Milliseconds < 90); // choice best option // Console.WriteLine((podsInfo[0] as OwnPod).GetAction()); // Console.WriteLine((podsInfo[1] as OwnPod).GetAction()); UpdatePods(podsInfo); foreach (Solution solution in Solutions) { solution.NextTurn(); } } }