TheMageLord said:
I never realized he did them. They're a lot different in comparison to his standard formation scripts, I thought someone else had reworked them heh.
No, that was me! I'm just seeing this, not having been around here much since we released the last version. It's nice having someone capable look over this stuff! Few people venture into that AI territory; it can get a little hairy.
If you don't mind, I'd like to incorporate the parts I like with the AI changes into what I did, credited as was Caba's material.
TheMageLord said:
They work great for moving archers around and flanking enemies, but are rather poor for big AI v AI infantry battles. The two boxes was just boring - they were spaced way out and didn't really do much fighting. But removing that limitation makes them move in lines, and the lines only work in certain circumstances.
The AI squares were meant to address the problems caused by the sheer geometry of large lines. When they rotated, the wings would lag horribly to the point of forming spirals.
The number 48 as a threshhold was not completely arbitrary. Trying to come up with a meaningful number, I did a bit of reading on close infantry formations. It turns out the long lines were a historical problem addressed various ways. I eventually went with the pre-reform Roman legions: three companies totaling 8 deep and about 50 wide, spaced 2m apart. I preserved the dimensions for three-line formations, hence 16x3. It DID seem small to me; but then that's why I made it a constant for modders to twiddle.
The original Roman formation was the phalanx, a formation that raises questions because it was often something of a square, as were shield walls. At the start of a clash, the majority were often not fighting, even as spears lengthened into sarissas/pikes to allow it. What was the point, then, to deep formations? I think it was to stuff as many men as possible into a given area in order to outlast the enemy. Anyhow, I was happy to keep three ranks, to generally allow all fighters to bear on a combat for speedy resolution, and, you're right, the squares undid this and moved it back to the perhaps the more historical case of attrition.
You're absolutely right that the
best use of the squares would be to move to battle position, then take formation. I simply didn't take the time to write this in.
AI formation spacing is based on swung weapon length. I noticed that formations spaced widely enough for their swung weapons do measureably better. Check out our AI in vanilla WB custom battle: Rhodoks in such a widely spaced square pretty much destroy anything. Historically, the Romans adopted an even more open, alternating (star) formation for the same reason (also flexibility), even though armed with primarily stabbing weapons: short swords and spears. It wasn't meant to stop an enemy like a shieldwall--it was meant to allow limited numbers in for destruction (as well as a surprise element from the third, veteran company hidden in back).
The problem was that the AI (to date) lumps both swung weapons (those that can't be converted to stab-only as normal) and stab weapons together. I tried spacing for average swung weapon length, but eventually (given the power of those 2H axes in WB), settled on spacing for the
longest. But let one axe into your spear formation, and they'll spread from shoulder-to-shoulder 47 cm (a historical value, BTW), to a meter-and-a-half! You'll see an exception in the code to exclude banners from causing that effect.
It'd be very nice to have separate AI "tracks" for stabbing and swinging infantry, making separate divisions. Caba's division typing (sdt_*) was a start in this direction, but we didn't take the time to finish exploiting it.
The distance between fighting formations was a bit of a bear, and I had trouble getting two AI squares close enough for a good fight, yet not meshing together. You've no doubt seen the extensive geometrical calculations in the code.
TheMageLord said:
Two evenly matched enemies it generally does good - the two big battle lines form and they clash. But when one side is made up of a smaller number of elite units (like, say, franks, or a player with a small tight formation) the formation just sticks in the big line even when the enemy is cutting a swath out of the center, and never encircles them. In that case the box would probably work a little better, but they'd still get wiped out by a charging enemy due to the distance between units.
I'll have to see if I can make things a bit better. Perhaps less initial spacing between units and a charge routine that kicks in once the fighting starts. Will have to try a few things and see how it works out.
You know, this occurred to me, but I didn't have the time to work it out.
Better and smaller units in fact form wedges to improve their chances. You're right in that the larger formation ought to try to whelm them.
I do have a whelm routine in the code. It tries to figure out whether it locally outnumbers the enemy 2:1, going into charge mode if so. It was actually meant for when one ranks formation contacts the end of another. There was some silliness as a formation would pop in and out as the numbers of enemy it was in contact with fluctuated around the threshhold, and I thought I had deleted it. Anyhow, the response you wrote for a ranks formation against a small, compact enemy is perfect!
Other stuff:
The lords stay out of combat to survive. In fact, they will also run off if the archers flee a lost fight. Reason: their troops will be out of formation
next phase without them. Not to mention they're needed back at home to collect taxes,
droit de seigneur, etc. They
do look idiotic just sitting there commanding troops. It'd be nicer if they rode about a bit, threatening to lop the heads off deserters, etc.
I'd dearly love to see lords more developed. Keep some for reserve if there are more than one. I think Treebeard wrote a battlefield player assassination routine for them for PoP. At least we talked about it.
That ought to discourage a player from going behind the enemy formation! Hence sdt_bodyguard.
TheMageLord said:
Well I went ahead and uploaded my changes. I tried various ways to get the infantry to fight better in formation, but simply ordering the infantry to hold fire and charge when the enemy is near (any enemy within 8 meters, enemy infantry or archer formation center within 15 meters) seems to be giving the best effect. They move across the field in formation, throwing weapons and such while approaching or facing off against each other, then swap to melee weapons and charge in.
Well, no secret from the formations forum, that was the big disappointment for me. Although historically there was a clear advantage to ordered, disciplined infantry, ordering and disciplining them in M&B
decreases their success. I've run many, many custom battles, and don't see why, other than troops in formation still act as if they are dueling, since that's the only way of fighting in the game engine. Also, troops in charge mode seem to get an awful lot of hits in despite being pretty much on top of one another. One suggestion from the formations forum was to implement the effect of the shield wall, to dissipate a hit on the shield of a neighbor. But in general, short of just kludging it, I feel I've exhausted all other approaches: stab-only weapons, back ranks not defending, etc.
Thanks for all the time I know you've put into this, and condolences on your mother's passing.