private float calculateTargetAngle(GameTime currentElapsedTime, Shooter shooter) { PriorityQueue<int, float> possibleShots = new PriorityQueue<int, float>(Comparer<int>.Default); const float interval = (Shooter.MAX_ROTATION - Shooter.MIN_ROTATION) / NO_SHOTS_SIMULATED; for (float angle = Shooter.MIN_ROTATION; angle < Shooter.MAX_ROTATION; angle += interval) { possibleShots.enqueue(new KeyValuePair<int, float>(new ShootSimulator(currentElapsedTime, shooter, angle).actionValue, angle)); } List<KeyValuePair<int, float>> bestShots = possibleShots.getBaseStorage().FindAll(shot => shot.Key == possibleShots.last().Key); return bestShots[RandomHelper.getRandom().Next(bestShots.Count)].Value; }