AI Path Finding (when cost = 100)

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

AI Path Finding (when cost = 100)

Post 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
goof2009
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 8
Joined: Fri Jul 01, 2011 4:20 am

Post 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? :)

:?: :?: :?:
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post 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!
pipfromslitherine
Site Admin
Site Admin
Posts: 9867
Joined: Wed Mar 23, 2005 10:35 pm

Post 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
Post Reply

Return to “Battle Academy : Modders Corner ”