Page 1 of 1

AI Path Finding (when cost = 100)

Posted: Sat Sep 17, 2011 9:03 pm
by Merr
Pip,

Last month I came across something after studying the AI scripts.

When developing random maps, I noted that when the AI's unit(team) sits across a water barrier with a destination that is on the other side, it doesn't understand that it needs to go around the water barrier ... It wants to go the shortest distance but it can't, so it basically comes to a stop and if you look very close ( :P ), you can see the AI units scratching their heads!

So, I looked into the matter ... I noted that the players "show route" (that we see) appears to be the same route that the AI looks at when moving to it's destination.

To fix the problem, in the terrainTXT file, I changed the water cost to read 900 :shock: .

In the following screen shot, you can see (now) the route that's calculated by this change. Also, I tested this with the AI unit (with both 100 and 900 ap) and the AI unit won't move when it's 100, but it will move (follow the route) when the water = 900 ap ... It's very interesting to say the least!

Image

Posted: Sat Sep 17, 2011 11:16 pm
by goof2009
I've come across this phenomenon too when checking path finding and have giving it some thought. My guess is that 100 really should be an infinite value. It should obviously be, as water is an infinite obstacle to a tank. But if the river were a thousand miles long it would send the tank up north "indefinitely". I can however see a reason to direct a tank to the location on "this" side of the river to at least get within gun range. So why 100? :)

:?: :?: :?:

Posted: Sun Sep 18, 2011 1:48 am
by Merr
I don't know exactly how they came up with 100 ... But, 100 works when the AI needs to "walk" (tile-by-tile) to it's destination. Also, if the unit was closer to the "crossing point" of the water, it would eventually work it's way around (the long way).

Basially, there is a "point-of-no-return" (as shown in the screenshot) where the AI will get stuck (logic wise). Actually, that point is further back than my screen shot shows, it's a matter of doing the math.

You don't see this in Slith scenarios (heavy scripting helps) ... But, under the right circumstances it gets ugly (random map).

There are probably thousands of path-finding solutions to consider. I've looked at few (script wise) and the AP cost of 900 was another (but not a good approach overall), as goof2009 has mentioned ...
goof2009 wrote: I can however see a reason to direct a tank to the location on "this" side of the river to at least get within gun range.
Chock this up as another "obstacle" ( :P ) to consider for random maps!

Posted: Sun Sep 18, 2011 5:24 pm
by pipfromslitherine
That is wierd. There should always be a valid route - although the AI does do some special logic to deal with partial routes and so on. I will have to look into what is going on. My guess for why 900 works is that it's wrapping around some of the stored values and calculations that happen inside the routefinding.

Certainly very odd. And as you say, a potential issue for random maps.

Cheers

Pip