Explore Courses Blog Tutorials Interview Questions
0 votes
in AI and Deep Learning by (50.2k points)

I'm implementing a simple Volleyball game using Box2D in Flash. I need to implement some AI for the CPU player. Let's call him Jack. So Jack needs to predict where's the ball gonna land after it has been hit by John, the human player. I have the following information :

  1. Initial Linear Velocity (both in x & y-direction) of the ball when John hits it.

  2. The initial position of the ball when John hits it. (x & y coordinate values)

  3. The value of gravity.

  4. The value of y position of the floor where's the ball's gonna fall.

  5. The angle at which John hits the ball.

  6. The ball follows a projectile trajectory.

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

I think as the ball follows a projectile trajectory the problem might be seen the same as that of - firing a cannonball from some known initial position, known initial velocity with fixed gravity and predicting its landing spot. The ‘y’ value of the landing spots is also known. The air resistance is zero.

Is there any kind of mathematical equation that might help to predict the x value of the landing spot? I took a look at some projectile equations but most of them take 'time' as a variable. I need to have a solution that doesn't involve this 'time' variable. Any kind of workarounds for this problem would also be appreciated. Thank you! :)

1 Answer

0 votes
by (108k points)

Let suppose, you have equation z in terms of t. So you have x = f1(t), y = f2(t), z = f3(t) where f1, f2, and f3 are some functions. After that we need to find the time t when the ball hits the ground; you can do this by solving the z equation. But at this time t, there will also be specific values of x and y, which can be found simply by plugging that number back into the first two equations.

If you wish to know what is Artificial Intelligence then visit this Artificial Intelligence Course.

Browse Categories