Objectmix
Tags Register Mark Forums Read

ballistics calculation algorithm for AI : Java-Games

This is a discussion on ballistics calculation algorithm for AI within the Java-Games forums in Other Technologies category; I'd like to calculate the throw needed to throw a ball to a certain point, for my AI. The terrain is a heightmap, but the wanted position might not be on the floor, since our game has a number of platforms and gadgets of various types. Also I'd need to avoid obstacles like trees and the such. The only way I could think of so far is making a few random throws with ghost balls in the overall desired direction, and iterate a hundred or so times per tick to see if we ever get there, but this is really ...


Object Mix > Other Technologies > Java-Games > ballistics calculation algorithm for AI

Java-Games Discussions about downloadable java games and other games developed in java

Reply

 

LinkBack Thread Tools
  #1  
Old 10-20-2008, 02:59 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default ballistics calculation algorithm for AI

I'd like to calculate the throw needed to throw a ball to a certain
point, for my AI. The terrain is a heightmap, but the wanted position
might not be on the floor, since our game has a number of platforms
and gadgets of various types. Also I'd need to avoid obstacles like
trees and the such.

The only way I could think of so far is making a few random throws
with ghost balls in the overall desired direction, and iterate a
hundred or so times per tick to see if we ever get there, but this is
really really stupid. There should be some way of at least calculating
a range of possible values. Can anyone point me somewhere?

Thanks
  #2  
Old 10-21-2008, 11:48 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: ballistics calculation algorithm for AI

On Monday 20 October 2008 15:59, Lacrymology wrote:
> I'd like to calculate the throw needed to throw a ball to a certain
> point, for my AI. The terrain is a heightmap, but the wanted position
> might not be on the floor, since our game has a number of platforms
> and gadgets of various types. Also I'd need to avoid obstacles like
> trees and the such.
>
> The only way I could think of so far is making a few random throws
> ... [PEB]


I start with the equation for a parabola (I assume your game works
with the standard approximation of constant gravity straight down).
That is, given the angle and force, where will it hit (at the same
height)? Invert it to get angle given force and target (including
height). (Or force given angle and target.)

Then add wind and air friction, if your game includes it.

Take derivative to find the maximum height. From this you can
compute, say, an angle to just clear an obstacle (assuming it is at
the apogee).

Better yet, find an equation giving the height given (a) distance from
the beginning, target, force, and angle. You can "walk" the path to
the target checking that the path clears each obstacle.

If the setting is in a cave, or more generally if there are obstacles
from above (e.g. roofs or stalactites) in addition to obstacles from
below (e.g. trees or hills), you can keep track of the maximum and
minimum angles that clears each one. If max is below min, you don't
have a clear shot.

If the equation ever gets too tough, you can stop with what you have
to find starting values. You could then try your ghost balls to
account for air friction or other things.

-paul-
Reply

Thread Tools



All times are GMT -5. The time now is 12:41 AM.

Managed by Infnx Pvt Ltd.