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:
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
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...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top