Simple equations for calculating path weight

  • Thread starter Thread starter vilu
  • Start date Start date
  • Tags Tags
    Path Weight
AI Thread Summary
The discussion centers on developing a method for calculating the optimal path for a spaceship in 3D space while avoiding collisions with static objects. Key variables include MIN_ALTITUDE, MAX_ALTITUDE, OBJECT_DENSITY, GROUND_POS_Y, and the coordinates of both the entity and objects in the game world. The goal is to create an equation that returns a higher path weight for coordinates that meet altitude requirements and have low object density. The proposed approach involves using limits to ensure the y-coordinate falls within the defined altitude range, and then adjusting the result based on object density. The developer emphasizes that the pathfinding does not need to adhere to physical laws, focusing solely on calculating a simple weight for various coordinates.
vilu
Messages
2
Reaction score
0
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.

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 separate 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...
 
Last edited:
Mathematics news on Phys.org
Does the path have to conform to any physical requirements? Like proper orbit mechanics? Or is it just a simple path finding exercise?
 
cpscdave said:
Does the path have to conform to any physical requirements? Like proper orbit mechanics? Or is it just a simple path finding exercise?

No it doesn't have to conform any physical requirements. I already have methods to take care of everything else. I just need to get simple weight for different coordinates based on min altitude, max altitude, world ground level, distance to ground from the entity and percentage (float between 0-1.0) of collidable objects along the position vector at those coordinates.

I already have methods to calculate percentage of those collidable objects, determinate the current ground level from the entity's position and changing variables to control min altitude and max altitude based on current task of the entity
 
Last edited:
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top