Statistical/graph math skills needed - find maximum of curve
by Thomas \"Man of Ice\" Lund · in Technical Issues · 09/11/2005 (2:40 am) · 3 replies
I'm coding up a distributed modular AI system to steer my ships.
Each module gives analog input to a given steering angle, and I'm now in need of math to find the maximum value where dx/dy = 0 for an approximated curve through all data pairs.
I have a hash_amp full of possible angles and each with a -1 to 1 value. -1 is "dont go here" and 1 "perfect way to go". Each AI module gives their input and I then need to find out where the best angle lies.
E.g. collision predictor module gives me a hash_map of
Angle -90, value 0
Angle -30, value -0.5
Angle -20, value -1
Angle 0, value 0
Angle 30, value 0
Telling me that the worst angle to go is around -20
while my pathfinding module would maybe give
Angle -40, value 0.7
Angle -30, value 0.9
Angle -20, value 0.1
Giving me a best angle somewhere between -40 and -30
My AI captain then balances the input from the various modules based on a FSM (patrol, guard, flee) and the type of ship he is (warship, transport, etc)
What I need now is a formula for approximating the curve going through these datapoints, so I can find all possible maximum values where dx/dy = 0
The math for approximating a curve eludes me, and I hope that someone out there can help me.
Each module gives analog input to a given steering angle, and I'm now in need of math to find the maximum value where dx/dy = 0 for an approximated curve through all data pairs.
I have a hash_amp full of possible angles and each with a -1 to 1 value. -1 is "dont go here" and 1 "perfect way to go". Each AI module gives their input and I then need to find out where the best angle lies.
E.g. collision predictor module gives me a hash_map of
Angle -90, value 0
Angle -30, value -0.5
Angle -20, value -1
Angle 0, value 0
Angle 30, value 0
Telling me that the worst angle to go is around -20
while my pathfinding module would maybe give
Angle -40, value 0.7
Angle -30, value 0.9
Angle -20, value 0.1
Giving me a best angle somewhere between -40 and -30
My AI captain then balances the input from the various modules based on a FSM (patrol, guard, flee) and the type of ship he is (warship, transport, etc)
What I need now is a formula for approximating the curve going through these datapoints, so I can find all possible maximum values where dx/dy = 0
The math for approximating a curve eludes me, and I hope that someone out there can help me.
Torque Owner Thomas \"Man of Ice\" Lund
I dumped the idea of using data pairs, and recoded my modules to return a suggested vector instead. Summing up all vectors prioritized (as suggested by several articles on steering behaviour) seems a better way to handle this architecture.
With that said, my immidiate needs are gone. But I would still like to hear how its done - for next time I need to approximate a graph