PDA

View Full Version : Siege AI, ladder blobbing and battle_config - results



Jambo
12-21-2006, 12:11
The attacking siege AI and the way it approaches the walls has always been one of the bugbears of recent TW titles. In Rome we had suicidal charges into phalanx units, buggy ladders and the large siege tower refusing to let the soldiers in. With M2TW, it’s better, but there are still some awkward pathfinding moments – my main one being the blobbing of units round the base of ladders that causes units to get stuck at the bottom and fail to climb, indefinitely. Blobbing on the ground seems to start when there’s a blockage on the exit area of the ladders at the top of the walls and may in part also be related to the variables in a particular xml file (see below). If soldiers from a unit get separated between ground and wall, the AI can’t seem to successfully issue the new orders to progress from the wall into the city. End result is an overall stagnation and a failure to progress.

However, the good news (I think!) is that at least with M2TW we’ve been given a chance to do something about it and that glimmer of hope lies within the battle_config xml file, the contents of which I’ve tried to elucidate below after an inordinate amount of time playtesting various settings in a custom battle (the custom battle involved the AI assaulting my city with 11 or so infantry units and 1 set of ladders and 2 siege towers). This type of situation usually equals pain for a human player defending and I don’t mean by the sword; I mean by the inevitable blob of units round the base of ladders causing an indefinite failure to negotiate from ground to wall and from wall into city.

So here’s a little rundown of my initial impressions of what various settings do –


<!-- should run be the default? -->
<default-run>1</default-run>
Undetermined. Setting to 0 seemed to have no effect.


<!-- distance within which soldiers will step onto the line (in metres squared) -->
<step-on-distance>4.0</step-on-distance>
I set this to 100 (i.e. 10 x 10) and all soldiers from the waiting units formed their blob further a-field from the ladders. Keeping them away further from the ladders seemed very good in preventing blocking and stagnation. Therefore, I’m thinking 225 (15 x 15) or higher may be even better.


<!-- start distance for the blockout region -->
<entry-blockout-inner>0.0</entry-blockout-inner>
<!-- end distance for the blockout region -->
<entry-blockout-outer>25.0</entry-blockout-outer>
<!-- limit on number of soldiers in the blockout region -->
<number-in-blockout>0</number-in-blockout>
The last of these set at 0 meant that the soldiers just fly towards the ladders even when the exit at the top of the wall is blocked. Setting the blockout range to the same as the step-on-distance and the number-in-blockout to around 4 seemed to work well and make soldiers stream to the ladders (in groups of 4) rather than run en mass. More testing is required with these settings.


<!-- queue length limit before movement will be stopped (in number of soldiers -->
<maximum-queue-length>10</maximum-queue-length>
Quite an important setting this one, as this seems to be responsible for (roughly) how many units can get onto the wall before the AI starts to blob at the bottom. Setting this higher (e.g. to 100) definitely seemed to give better results, although realism may be strained a little. Again more testing required.


<!-- when the entrance to a line is blocked all of the soldiers are stopped. -->
<!-- once the entrance is clear then the first x soldiers will be restarted moving. x is set below -->
<restart-threshold>10</restart-threshold>
Haven’t had much success in determining what this variable does exactly, although I think it’s related to the reinitiating of soldier movement once a blockage at the top of the ladders is cleared. Setting higher would seem a more logical approach, but might effect PC performance more (didn’t effect my high-end machine though).


<!-- when the entrance to a line is block any soldiers beyond this position in the queue will be halted. -->
<halt-threshold>-1</halt-threshold>
Again, it was difficult to determine the effect of this variable in what limited testing I did with it. What does the default of -1 actually mean? Maybe setting this to a high positive value will keep soldiers flowing better by preventing all the soldiers that are waiting to get to a line from halting when there’s a block? Definitely more to be tested.


<!-- do the soldiers have to enter in a precise order? -->
<precise-order>1</precise-order>
Didn’t seem to have much effect when I changed to 0. Siege towers have this as 0, ladders as 1. Seems logical, but more to be tested.


<!-- distance soldiers should stop at if the entrance is blocked (in metres squared) -->
<stand-off-distance>25.0</stand-off-distance>
<!-- distance soldiers should stop at if the queue is too long (in metres squared) -->
<long-queue-stand-off-distance>64.0</long-queue-stand-off-distance>
These are settings which didn't seem to impact as greatly, although I did keep these in proportion to changes I made to the step-on-distance and blockout limit. Possibly higher for both is better.

So far my best results with the AI and its ladder usage have come with setting the step-on-distance and maximum-queue-length higher, as well as making the AI stream more by setting the number-in-blockout to greater than 0. It’s a tricky process because there are many variables to examine and they’re clearly inter-dependent. I intend to release a battle_config mod at some point, but only once I’m truly happy with the modifications I’ve made. Any other feedback from willing testers could greatly speed this process up. I just repeated the same custom battle over and over, and possibly a different type of siege setting, e.g. multi-walled castle, might produce very different results.

:hmmm:

Regards

Jambo
12-21-2006, 12:15
I should say all tests were done using the LARGE unit size. Huge might have a massive impact on results seen here. Normal or small would probably be much easier for the AI.

Bob the Insane
12-21-2006, 14:03
Nice work, does setting the values you noted actually prevent the apparant lag we see when the bloging gets worse?

Jambo
12-21-2006, 14:49
Well, to be honest, I've haven't experienced that major lag issue with the new patch yet, although I did drop down to Large unit size recently and that would help in itself. I did get the lag a few times pre-patch with huge units.

Does it still occur post-patch? If so, then I imagine changing these values to improve the AI's method of using ladders would definitely help! I reckoned the lag was pretty much caused entirely by the pathfinding chaos caused by ladder blobbing.

Jambo
12-22-2006, 00:28
Ok, I'm ready to release something which changes quite a bit the way siege AI works. Here is the ladder section of the battle_config xml file with the new values:


<!-- should run be the default? -->
<default-run>1</default-run>

<!-- start distance for the blockout region -->
<entry-blockout-inner>0.0</entry-blockout-inner>

<!-- end distance for the blockout region -->
<entry-blockout-outer>225.0</entry-blockout-outer>

<!-- limit on number of soldiers in the blockout region -->
<number-in-blockout>2</number-in-blockout>

<!-- distance soldiers should stop at if the entrance is blocked (in metres squared) -->
<stand-off-distance>324.0</stand-off-distance>

<!-- distance within which soldiers will step onto the line (in metres squared) -->
<step-on-distance>400.0</step-on-distance>

<!-- queue length limit before movement will be stopped (in number of soldiers -->
<maximum-queue-length>10</maximum-queue-length>

<!-- distance soldiers should stop at if the queue is too long (in metres squared) -->
<long-queue-stand-off-distance>324.0</long-queue-stand-off-distance>

<!-- when the entrance to a line is blocked all of the soldiers are stopped. -->
<!-- once the entrance is clear then the first x soldiers will be restarted moving. x is set below -->
<restart-threshold>10</restart-threshold>

<!-- when the entrance to a line is block any soldiers beyond this position in the queue will be halted. -->
<halt-threshold>-1</halt-threshold>

<!-- do the soldiers have to enter in a precise order? -->
<precise-order>1</precise-order>

Essentially, the critical point is having the step-on-distance higher than the other variables. What this does is it means all units waiting to get onto the ladder at the start of a siege are considered within the step-on-distance before the other variables which can cause them to halt kick in. The net result in the AI being able to get all/nearly all of its soldiers up to the walls at the first attempt. There are situations where this won't always happen, but for the majority this works pretty well every time.

Also included is the same trick for the siege engines, so soldiers should climb the siege engine quicker.

Have fun and be prepared to sweat under AI sieges.

Feedback always appreciated.

Find the modified battle_config file here:
http://www.twcenter.net/forums/showthread.php?p=1395211#post1395211