path cost is always zero

path cost is always zero

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

path cost is always zero

Post by Shaitan »

the following code

Code: Select all

...
for(std::vector<springai::AIFloat3>::iterator i = metalSpots.begin(); i != metalSpots.end(); ++i) {
...
int length = callback->GetPathing()->GetApproximateLength(commanderUnit->GetPos(), *i, 0, 8.0f);
...}
...
always returns zero path cost:
armcom position: (2565.161133, 120.874695, 4570.481934)
spot position: (5960.000000, 2039.000000, 520.000000)
length: 0
spot position: (9720.000000, 2039.000000, 776.000000)
length: 0
and so on.

why is that?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: path cost is always zero

Post by AF »

My initial thoughts are that you have found a bug in the wrapper generation. This will require further investigation
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

Re: path cost is always zero

Post by Shaitan »

shall i report the bug? can you inform those who need to know about it?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: path cost is always zero

Post by AF »

Mantis is where bug reports go:

http://springrts.com/mantis/my_view_page.php
Shaitan
Posts: 16
Joined: 04 Jan 2014, 11:54

Re: path cost is always zero

Post by Shaitan »

looks like the returned zero is a path ID, which i'm supposed to pass to

Code: Select all

springai::AIFloat3 GetNextWaypoint(int pathId)
but that function always returns an invalid AIFloat3. so i'm still stuck.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: path cost is always zero

Post by AF »

It's times like this I wish we had doxygen or some other docs, I don't know what the arguments for that method are called from memory or have the headers at hand
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: path cost is always zero

Post by abma »

callback->GetPathing()->GetApproximateLength(commanderUnit->GetPos(), *i, 0, 8.0f);

thats a wrapper arround this function it seems:
float GetPathLength(float3 start, float3 end, int pathType, float goalRadius);

and i guess pathType is something from the unitdef, is there a pathType? but imo it makes no sense to set it to 0, thats what kloot meant with "wrong input parameter" i guess.

Code: Select all

* @param pathType  For what type of unit should the path be calculated
next time grep the source code of spring for "GetApproximateLength". :)

edit: more code:
https://github.com/spring/spring/blob/d ... k.cpp#L735
cleanrock
Former Engine Dev
Posts: 115
Joined: 21 Feb 2009, 07:42

Re: path cost is always zero

Post by cleanrock »

This is the doxygen text for GetApproximateLength:
/**
* Returns the approximate path cost between two points.
* - for pathType @see UnitDef_MoveData_getPathType()
* - goalRadius defines a goal area within which any square could be accepted as
* path target. If a singular goal position is wanted, use 0.0f.
* default: 8.0f
* @param start_posF3 The starting location of the requested path
* @param end_posF3 The goal location of the requested path
* @param pathType For what type of unit should the path be calculated
* @param goalRadius default: 8.0f
*/

I had some trouble finding info about pathType/UnitDef_MoveData_getPathType but hopefully it makes sense to game devs.
Post Reply

Return to “AI”