示例#1
0
        // Returns a hittable point on the ball.
        private Vector3 getHitPoint(rlbot.flat.GameTickPacket gameTickPacket, rlbot.flat.BallPrediction prediction)
        {
            Vector3 carLocation = fromFramework(gameTickPacket.Players(this.index).Value.Physics.Value.Location.Value);
            double  u           = fromFramework(gameTickPacket.Players(this.index).Value.Physics.Value.Velocity.Value).Length();

            // Estimate the maximum velocity.
            double maxV = Math.Max(1410, Math.Min(2300, u + 150 * gameTickPacket.Players(this.index).Value.Boost));

            for (int i = 0; i < prediction.SlicesLength; i++)
            {
                Vector3 point = fromFramework(prediction.Slices(i).Value.Physics.Value.Location.Value);

                double s = Vector3.Distance(point, carLocation) - 92.75;
                double t = (double)i / 60D;
                double v = 2D * (s / t) - u;
                double a = (Math.Pow(v, 2) - Math.Pow(u, 2)) / (2 * s);

                if (v <= maxV && a < 1700) // Approximate max acceleration.
                {
                    renderPrediction(prediction, 0, i, System.Windows.Media.Color.FromRgb(255, 255, 255));
                    return(point);
                }
            }
            return(fromFramework(prediction.Slices(0).Value.Physics.Value.Location.Value));
        }
示例#2
0
 // Renders the prediction up to a certain point.
 private void renderPrediction(rlbot.flat.BallPrediction prediction, int start, int end, System.Windows.Media.Color colour)
 {
     for (int i = Math.Max(1, start); i < Math.Min(prediction.SlicesLength, end); i++)
     {
         Vector3 pointA = fromFramework(prediction.Slices(i - 1).Value.Physics.Value.Location.Value);
         Vector3 pointB = fromFramework(prediction.Slices(i).Value.Physics.Value.Location.Value);
         Renderer.DrawLine3D(colour, pointA, pointB);
     }
 }
        public Slice this[int index]
        {
            get
            {
                if (index < 0 || index >= Length)
                {
                    throw new IndexOutOfRangeException();
                }

                return(new Slice(flatprediction.Slices(index).Value));
            }
        }
示例#4
0
 // Returns the location of where the ball will first hit the ground
 private Vector3 getBounceLocation(rlbot.flat.BallPrediction prediction)
 {
     for (int i = 0; i < prediction.SlicesLength; i++)
     {
         Vector3 point = fromFramework(prediction.Slices(i).Value.Physics.Value.Location.Value);
         if (point.Z < 125)
         {
             renderPrediction(prediction, 0, i, System.Windows.Media.Color.FromRgb(255, 0, 255));
             return(point);
         }
     }
     return(fromFramework(prediction.Slices(0).Value.Physics.Value.Location.Value));
 }
 public BallPrediction(rlbot.flat.BallPrediction ballPrediction)
 {
     Slices = new PredictionSlice[ballPrediction.SlicesLength];
     for (int i = 0; i < ballPrediction.SlicesLength; i++)
     {
         Slices[i] = new PredictionSlice(ballPrediction.Slices(i).Value);
     }
 }