AI operating physics-based vehicles?

chmod

08-02-2008 20:35:49

Greetings all,

I have a fairly far along space-sim I'm working on. I've had joystick support working for flying the ship, and all the inputs add the various forces and torques to allow a basic flight model.

Now as I'm starting to implement AI for other ships in space, almost all documented AI has to be thrown out the window because the ships are operating with lots of unknowns. (I.E. there is no max speed because it's in space and it's just mass and acceleration potential)

Is using the physics engine to apply forces for ship steering actually a good idea? I'm starting to see why lots of games just use it for nice effects and not core gameplay.

Instead of being able to leverage years of AI wisdom, my movement functions end up looking like a high-school calculus test gone wrong.

Anyone have any opinions on this? Are there better ways to use the physics engine in a more reasonable way for ship movements?

betajaen

08-02-2008 21:28:59

There are two/three ways on how I can see it:

- Control the ship normally using forces. Programming the AI will be more difficult, like when you need to apply counter forces to balance out a turn.

- Control the ship "arcade" like. The AI will be easier to make, but the Physics will be less realistic and less stable.

- Combine the both together. The AI will use an arcade system (forward/backward/left/right) to control the ship but an in between set of code would calculate the forces required; and apply them when needed.

It's really up to you. I've seen both examples of some of these (Frontier Elite II for one, Homworld, etc.) and they've all turned out pretty well.

chmod

08-02-2008 21:54:46

Right now I'm currently relying on damping settings to counter the rotations, do you think it would be better to apply counter forces manually to reach equilibrium after the input returns to center?

Also isn't it expensive to be calculating needed forces (based on mass and force) for each movement? My physics is a bit rusty as far as angular momentum goes. :)

gugus

09-02-2008 13:25:27

(I.E. there is no max speed because it's in space and it's just mass and acceleration potential)
I am not realy in topic,but light speed is the max speed.Dont forget E=mC²

Vectrex

09-02-2008 15:08:50

you could try using a neural net lib like FANN. Would be good for the sort of fuzzy concepts of space navigation

chmod

09-02-2008 17:49:08

(I.E. there is no max speed because it's in space and it's just mass and acceleration potential)
I am not realy in topic,but light speed is the max speed.Dont forget E=mC²

*snicker*

you could try using a neural net lib like FANN. Would be good for the sort of fuzzy concepts of space navigation
I was actually thinking about something like that but thought it might be overkill, and also way too big of a resultant lookup table to be used in real time with any significant number of ships. But I'll check it out. Thank you.

betajaen

09-02-2008 19:53:49

(I.E. there is no max speed because it's in space and it's just mass and acceleration potential)
I am not realy in topic,but light speed is the max speed.Dont forget E=mC²

*snicker*


Yes. But you could only enjoy ~14 seconds worth of traveling at that speed before the NxVec3 reaches it's maximum size of a float. :?

14 seconds isn't worth it.

Game_Ender

09-02-2008 20:00:34


- Combine the both together. The AI will use an arcade system (forward/backward/left/right) to control the ship but an in between set of code would calculate the forces required; and apply them when needed.


That is how its done in the "real world". The computer decides it wants to turn left. A controller monitors the current and desired vehicle state and based on the difference computes the forces and torques should be applied to the vehicle. It then maps those forces and toques to the control surfaces and engines of the vehicle.

The project in my sig uses this approach to control both out real submersible and the simulated vehicle (Ogre + OgreNewt).

chmod

09-02-2008 20:06:31


- Combine the both together. The AI will use an arcade system (forward/backward/left/right) to control the ship but an in between set of code would calculate the forces required; and apply them when needed.


That is how its done in the "real world". The computer decides it wants to turn left. A controller monitors the current and desired vehicle state and based on the difference computes the forces and torques should be applied to the vehicle. It then maps those forces and toques to the control surfaces and engines of the vehicle.

The project in my sig uses this approach to control both out real submersible and the simulated vehicle (Ogre + OgreNewt).

Quite interesting, Game_Ender. Thanks for solidifying what I was starting to lean to :)

One question. How do you guys deal with "roll" of the vehicle? Given say a spacecraft or submersible? What I mean is that roll doesn't actually get your vehicle any closer to a given target vector. Pitch and yaw are easy using dot products, but I'm still struggling with why an AI would ever roll any amount.

betajaen

09-02-2008 20:17:40

Apart from looking cool; Rolling in space doesn't do anything to the turn of the spacecraft; unless it can enter an atmosphere. I'd leave it out for now.

chmod

09-02-2008 20:33:19

Apart from looking cool; Rolling in space doesn't do anything to the turn of the spacecraft; unless it can enter an atmosphere. I'd leave it out for now.

But a human pilot (even in space) will often roll to put something in his ZY plane for visibility. I've watched friends play my sim and they frequently roll to get a better visibility angle. I was thinking of using a cross-product to bring the target vector into the ship's ZY plane (mimicking what a human would do to get the target visible in a vertical aspect).

This sounds harder, so maybe I should just never let the AI roll.

Vectrex

10-02-2008 01:43:47

(I.E. there is no max speed because it's in space and it's just mass and acceleration potential)
I am not realy in topic,but light speed is the max speed.Dont forget E=mC²

*snicker*

you could try using a neural net lib like FANN. Would be good for the sort of fuzzy concepts of space navigation
I was actually thinking about something like that but thought it might be overkill, and also way too big of a resultant lookup table to be used in real time with any significant number of ships. But I'll check it out. Thank you.


Actually from the little I've used NN's they are both small and really fast. It's the training which is very slow but once they are trained it's lighting fast to actually use them.
I tried it in our kart simulator and to my surprise after watching me for a few laps it could drive round the track, braking and steering
Not saying that NN's are the solution but for something like natural looking space manovours it sounds worth it

ps I never understand what 'overkill' means. If it's easy, fast and cool :)