Cause the question "Is it possible to build an advanced Siege AI" came up in the "Invading adventurers" Thread and i didnt want to disturb the ongoing discussion there, i decided to suggest an Approach on more advanced sieging Ai here.
I want to begin with an qoute from the above mentioned "Invading adventurers" Thread:
I'm sure that having siegers learn your defenses and take steps to counter them in future attacks has been suggested, but I thought a specific implementation could be counts of how many died and in what way. So it would not just count deaths, but count deaths by way of: melee combat; ranged combat; siege engine fire; kill-traps; cage traps; falling or other bridge-related actions; drowning; and burning by magma. Then the next time, bring along some sort of counter to that defense.
For instance, if a lot of attackers are lost to traps, they might eventually start herding cannon fodder into them to set them off without "real" losses. If a lot of attackers fell to Marksdwarves in a few sieges, they could bring along catapults that would fire projectiles that could splash through fortifications, or marksgoblins with Pavises. If a lot of attackers drowned, they might bring an amphibious unit that could destroy underwater buildings. And if there's a trend of attackers being chopped up by axedwarves, a few adventurers in =steel plate mail= would work them over but good.
Excellent ideas. Also, the game could use civ-specific "traffic designations" so that invaders could try to avoid spots where their comrades died to traps earlier.
Excellent ideas or not, I am not sure that it's possible to create an advanced AI like that. Toady is a magician, so maybe he could code in an AI like that, but to be honest, I will be very happy if we gonna have a "working" tunneler system even.
First off i think it wouldnt be that hard to find an way for an siege AI.
The problem the current siegers have are from my point of view are 3.
- They dont learn from Mistakes
- They cant destroy Walls or cross moats and other stuff
- They are to straight forward.
To solve this problems i want to line out some ideas.
1. LearningAn Siege Ai should have an way to "learn" certain things. If you want to Learn you need informations. The Information system i envision has 3 parts:
- The in the quote mentioned "killcounter"
- Some sort of Map for the Ai. This map would have:
- An plan of your the terrain.
- An plan of encountered moats, walls
- Mele-zones. - Zones were your Siegers are killed by the besieged in melecombat
- Ranged-zones. - Zones were your Siegers are killed by the besieged with Bows/crossbows/Siegeweapons and from where the bolt came.
- Dangerzones. - Same as killzones but for falls, Smashers and Drowners.
- Trapzones. - Same as killzones only for traps
- Lootzones. - Quarters, Stockpiles, Baracks.
(- Entrancepoints.)
- an Objectiv system which determines what has to be done to avoid loses and deal with "Stuff" at the same places as before by the Knowledge gathered before the recent siege.
The Informations for the first siege can be gathered by snatcher, Thiefs and "Scouts" (Invisible and Trapavoid).
Lets asume th Gobs try there first siege on your fortress and send out snatchers as well scouts. How would the information gathering work?
The Snatchers as the Scouts can see stuff right? So say an scout sees an wall with an marksdwarf on it or Fortification. The area of an Bowshot around the wall now gets marked as "Ranged-zone", if an siegeweapon is seen for an siegeweapons range. The wall itself gets marked naturaly too.
Meanwhile the Snatcher enters the fortress. He walks over some traps without activating them. The tiles with encountered traps of any sort are marked as Danger-zones. On his way trought the fort he sees too Baracks and Weapon-stockpiles which get marked as Mele-zones. An encountered r Bridge gets marked as Dangerzone. Quarters and valueable Stockpiles are marked as lootzones by our goblin.
Should one of our Scouts or Snatchers leave the map via the mapedge he brings the infos back to our Goblinculture.
Same goes if the siegers attack, get beaten, and retreat with some minor differences. Rangedzones get assigned to places were Gobs etc are killed by ranged weapons. This area gets now expanded one bowshot in the direction from there they did come.
Now kicks the real AI in by determining the priority of targets and how they are handeled (an "deal with order" if you want). If you are an sieger you would set prioritys too. Surely baracks and weaponstockpiles get the highest cause this places are the ones were the most resistance can be asumed, Thought diffenernt siegers have different prioritys. To reach that priority targets we can use the standart Pathing with some Modifications. Normaly the shortest direct path is seeked, here we seek the "safest" path. This can be done if we use our priviously marked "Zones" by giving this zones an higher value to path trought.
2. Dealing with "Stuff" on the Path in and Pathvalues.We have now our path but we have to still deal with the things we will encounter.
Traps could be disabeled by by engineers or by driving "Meat" throught it they get an pathvalue of 20.
Atom Smasher could be disabeled by "supports" or by newlybuild walls. They should get an very high pathvalue like 10000.
Known Danger zones get no pathvalue instead they get marked an impassable so this way our siegers would path around it.
Moats (pathvalue 25?) get "filled" or bridget as long they arent covered by an rangedzone. If they are covered by an Rangedzone the Sortingalgorithm of the prioritytargets rates the source of the rangedzone higher so it gets destroyed before the moat is crossed. "Destroyed" means killing marksdwarfs/violent deconstruction of dwarven artilery with own siegeweapons or Ranged military.
2.1 Walls Climbing and Digging
Not only digging should be possible for siegers building siegeweapons and other stuff should be an option to get around player and dwarf made defenses. Even climbing an wall could be an good tactic.
Walls get an very high Pathing value say 150. Walls that overlap with Rangedzones get sheduled for being shot with siegeengines if this Zones overlap with our path. If an wall without Rangedzone is in the way an there is only an long dangerous way around it or no way around it, it gets torn down by Buildingdestroyers (trolls) or if in range of one of the siegeweapons by those.
Our trolls should atack an by ranged weapons defended wall if an siegeweapon cant be brought in position for this wall. The Ai should here Rate the Trolls lower then siegeweapons and reenforce them with the aid of ranged troops.
Digging (if tunnelers get in) digging gets an value of 300. Damp and Hot walls should be avoided.
Climbing an wall should be possible only for some creatures thought climbing an wal schouldnt be so fast there should be an chance to fall and the sieger should have an very low hitchance if he attacks during climbing. Climbing in very heavy gear should be harder.
Since the Siege Ai knows what kind of resistance it has to deal with and how it should select the right kind of siegers too. An heavy trapped and walled of fort needs more siegeweapons and Trapdestroyers then an fort with an palisade and 50 Axemen.
(Additional tactics would be possible if "siegeshields" against Ranged weapons, Mobile bridges for crossing moats, and mobile Ramps could be moved too into the Batle too.)
3. Breaking straight forwardnessThe straight forwardness of the sigers is one mayor problem. If there is one way in they use that way without thinking currently. Even with The Points 1 and 2 implemented the attacks the players will see would get predictable with the time.
This can be handeled by some things.
First of the Siege Ai could not only math out one way in it could math out different a bit more unlikely ways.
Different plans at the same time. the Siegers could try to break in the fort on 2 or more different spots.
3.1 Sidebhavior (Tortureing the besieged).
The siegers can torture our besieged fort in different ways.
One way is shooting the surface fort to dust: The typical grinding siege if you want.
Poisoning the watersource: is another. If the fort has one mayor watersource like an river or brook it can be poisoned making the dwarfs inside of the fort sick.
Start Fire and theft: Once inside an fort it would be devasting if the siegers could destroy your Farmplots and even more so if they burn your wood and Foodstockpiles. The siegers could also grab valueables and better equipment if they get there Hands/Paws/Claws/Tentakles/Pseudopods on your fallen military or the weapon, armor and ammo Stockpiles.
Freeing captives: If there are captives in the fort te siegers could free them so they join in there fight or produce chaos if there are creatures found.
Slavehunting. This could be one of the mayor causes for an attack too. After the siegers broke into the fort they try to knockout or only wound Children and untrained dwarfs so the following slavedrivers can collect them.
Bridgeheads. Once inside the fort the sieger could errect Bridgeheads. By stationing guards and building provisoric defensesystems by manipulating your traps and with enought time setting up own traps.
Freeing HFS: Do i have to say more?
I hope this Suggestion was entertaining and not to full with mistakes. If there are question i try to answer them all. Feel free to discuss and to show me my failures if i made them (only logical ones please i know that my english is horrible).