Spherical Prediction - Artificial Intelligence

I implement a simple volleyball game using Box2D in Flash. I need to implement AI for the CPU player. Let him call Jack. So Jack needs to predict where the ball will go after hitting John, the man. I have the following information:

  • The initial linear speed (both in the x-direction and in the direction) of the ball when John hits it.
  • The starting position of the ball when John hits it. (x and y coordinates of value)
  • The value of gravity.
  • The y value of the position of the floor where the ball will fall.
  • The angle at which John hits the ball.
  • The ball goes along the trajectory of the projectile.

So, Jack needs to predict what the position (x value) of the ball will be when it hits the floor.

I think that since the ball follows the trajectory of the projectile, the problem can be seen in the same way as firing from a cannonball from some known starting position, a known initial speed with fixed gravity and predicting its seat. The y value for landing is also known. Air resistance is zero.

Is there any mathematical equation that could help predict the x value of the footprint? I looked at some of the equations of the projectile, but most of them perceive "time" as a variable. I need to have a solution that does not include this time variable. Any kind of work on this issue would also be appreciated. Thanks!:)

+4
source share
3 answers

If you have an equation for z (i.e. height) in terms of t , then you need to decide what for z = 0 to get the value of t when the ball lands. You can then put this back into the equations for x and y .

+2
source

You must solve z (x) = 0 using this equation: g is gravity, v0 is the initial velocity along the x axis, and a is the angle.

Equation of z with x variable

When you solve it, it gives the length of the segment connecting the start point and the end point (select one end point depending on the direction of the hit).

Resolution

If you are in 3D, you will need to make some predictions to remove the 3D part of the problem and save only two axes.

+1
source

The initial linear speed (in both x and y direction) of the ball when John hits him.

The starting position of the ball when John hits it. (x and y coordinates of value)

The value of gravity.

And the direction is the negative y-direction, of course. 32.2 ft/sec^2 = 9.8 m/sec^2 , right?

The y value of the floor position where the ball will fall.

He will hit y = 0 if the other player does not touch him.

The angle at which John hits the ball.

I think it would be better to say something about the force that John applied to the ball and for how long.

The ball follows the trajectory.

No, you do not have such a thing. This is what you are trying to solve.

You have Newton's law: F = ma, where force is the vector of the force applied to the ball, m is the mass of the ball, a is the acceleration vector applied to the ball.

The ball is accelerated by gravity in the negative y direction, of course, but you forget the force vector that the player applies when the ball hits.

Once you have those, you solve two related ODEs in time.

0
source

All Articles