I'm a mod developer and I would need some help to calculate best path/route to take for an entity. To keep this post more math related than game programming related I'll try to explain this process easily. Basicly the entity (spaceship) tries to fly in 3d-space from point A to point B and it should avoid for collision with any other static objects.(adsbygoogle = window.adsbygoogle || []).push({});

What I'm trying to do is to calculate the best possible path depending these variables:

Variable: Value and definition

MIN_ALTITUDE: Usually 14.5, distance to ground

MAX_ALTITUDE: Usually 60.0, max distance between ground and entity

OBJECT_DENSITY: Value between 0.000000 and 1.0, percentage of objects in specific coordinates and direction from entity, 0 = clear, no anything to collide with 1 = lots of objects or the ground for example (collision happens for sure)

GROUND_POS_Y: Y coordinate which is on the ground and will be below the ground if smaller than this

WORLD_COORDINATES: X Y and Z position of the objects in game world

ENTITY_COORDINATES: X Y and Z position of this entity in game world

When I call method getPathWeightFor(xCoord, yCoord, zCoord) it should return bigger number for better coordinates which are better if OBJECT_DENSITY low (more lower, better), yCoord < GROUND_POS_Y + MAX_ALTITUDE, yCoord > GROUND_POS_Y + MIN_ALTITUDE

And this is the path weight. It could be something between -10.0 and 10.0, if OBJECT_DENSITY equals 1.0 then negative or if yCoord > GROUND_POS_Y + MAX_ALTITUDE then also negative so the AI considers it as bad choice. AI runs getPathWeightFor() method for multiple coordinates at ones and then chooses coordinates that got highest value from that method.

To clarify somethings: Variables I introduced are calculated by seperate methods so there is no need to think about how those things could be calculated, and so is the actual path finding too. Actual path finder does ray trace from entity to semi-random coordinates and then collects calculated path weights for different waypoints. After path finder has coordinates and weights for them in its collection, it sorts collection list and returns coordinates which got highest path weight value.

So, what kind of equation I should use to get best coordinates so that entity would usually keep at least MIN_ALTITUDE and only rises towards MAX_ALTITUDE if there is no better path? Sorry if this post is hard to follow, but its hard to explain complicate things :D

Edit: After doing some research I think the formula I'm looking for has something to do with limits, because when testing given coordinates (in this case y-coordinate) formula should return higher number when y <= groundPosY + maxAltitude and y >= groundPosY + minAltitude. After getting that result I could multiply result with objectDensity and that would give me the weight. I know that there is some formula to get value of how far from two limits give y-coordinate is, just can't figure it out...

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Simple equations for calculating path weight

Loading...

Similar Threads - Simple equations calculating | Date |
---|---|

I A Simple Equation, but a Complicated Solution | Jan 21, 2017 |

A seemingly simple linear algebra equation that eludes me | Nov 14, 2015 |

Solving for a variable. Hard to do in this simple equation. | Feb 4, 2015 |

Problem with a 'simple' equation? | Jan 25, 2015 |

How to derive a simple profit equation. Kinda embarrassing. | Nov 15, 2014 |

**Physics Forums - The Fusion of Science and Community**