Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Algorithmic suggestions to improve sieges.  (Read 3601 times)

Zemat

  • Bay Watcher
  • Zemat, programmer, cancels coding: Too insane.
    • View Profile
Algorithmic suggestions to improve sieges.
« on: August 27, 2008, 02:55:57 pm »

So far we have already suggested a lot of improvements for sieges but most of them have focused on content (siege weapons, moat crossing, etc). Here I'm going to focus on possible improvements to the algorithm used by current siege forces to improve their AI and increase their difficulty. The suggestions are fairly simple so I won't use programming lingo that much.

-- Tactics of the invading army:

Once more complex units are added into the game (moving siege units like ballistae and catapults), invading forces could be better organized with different formations and tactics depending on how well the previous siege went. That is, the game could keep a more detailed score which registers the reasons for the siege failure. For example.

  • If most of the previous invading force died to marksdwarves then the next attack should consist of ranged units, specially ranged units that can take onto fortifications. Like for example ballistae and catapults that can bring down marksdwarves' towers.
     
  • If the bulk of the invading force died in hand-to-hand combat then the next force should include more experienced melee weapon users and bigger units like trolls and mounted warriors.
     
  • If traps where the scourge of the previous invading force then the next one should carry a decent amount of thief-like units that not only are able to pass over traps without activating them but also able to deactivate them for the other units. The only restriction is that these special units should advance more slowly when deactivating traps. This will give dwarves an opportunity to kill them before they open the way to the rest of the force.
     
  • If on the other hand the fortress is basically impregnable (moats, drawbridges, etc), or if the previous force died due to unaccounted reasons (weird traps, lava traps, degrinchinators, etc), then the next invading force should go in with a destroy everything mentality and instead of trying to penetrate, they will try to bring down the fortress by some equally impressive means. The one that occurs to me is for the invading force to dig a channel from a river or magma vent directly into the fortress entrance and pump water or magma into it and try to kill everything inside without entering. That is, in the immortal words of Ellen Ripley:

    "I say we take off and nuke the entire site from orbit. It's the only way to be sure."

Basically this is a rock/paper/scissor system where the invading force changes tactics for each siege to counter the most important defenses the fort currently has.

-- Penetrating fortresses:

This is a thoughy one. How an invading force will be able to penetrate a fortress with no access? It's easy to say that besiegers should be able to build bridges to cross moats and dig onto terrain to reach underground places. But the fact is that this might require severe AI improvements. Here I propose some simple AI improvements that would make it easier for invaders to make complex decisions:

  • Pathfind over obstacles: This one is somewhat simplistic. If the regular pathfinding algorithm can't find a way into the target, then, instead of using the regular connectivity path for the pathfinding algorithm, the invading force should simply take the map as if it where empty (no ground, no walls, etc) and instead try to build it's own road to the target. The algorithm creates a direct path and then the invaders walk until finding obstacles. Then they use some technique to get over it. If there's a moat, the invaders will auto-designate some trees to cut and use them to build a bridge. If the target is behind a wall then the enemies use wall-destroying units (trolls, catapults). If the target is underground then the invaders will dig their way into it. And if the target is on the sky they should build a skybridge to it. The only exceptions to this pathfind-over-everything would be water bodies and lava. Because we don't want invaders inadvertently dig into a river and drown themselves, they must dig or build around them when possible. If for some reason the invaders can't possibly get over an obstacle (having no diggers, woodcutters or trees to cut), then the siege is essentially called off (instead of lingering there for ages). Then in the next siege they could bring what they need to get to the target.
     
  • Target buildings, then units: Right know besiegers seem to use the pathfinding algorithm to target enemy units on the map and walk to them. But this only serves to make besiegers disperse too much and focus on unimportant targets. Also, if the pathfind-over-everything algorithm is implemented it wouldn't probably work if the target unit is moving constantly forcing siege-builders to cancel jobs and pathfind a new bridge or tunnel every minute. I say that besiegers should instead target any buildings (including beds) and designated areas like rooms and halls first. Then, when they get close to the targeted building, they first kill any target of opportunity (near dwarves) then destroy or burn the building.
     
  • Besieging groups should act as single units: I don't know how individual invading units act now. But they spread too much for my taste. Invading forces should concentrate on their leaders and try not to get too far from them. Being closer to the leaders should have more priority over following targets. Also, only the group leader should be able to pathfind-over-everything and target buildings. Only when an specific obstacle appears then the leader gives individual jobs like tree-cutting, digging and building to his/her minions. This also implies that, if the group leader dies, the group should disperse and flee. Giving tactical importance to taking out leaders first.

This is all for the moment. Sorry for the long post but I didn't want to spread the suggestions over several posts specially because they reference each other.
« Last Edit: August 28, 2008, 02:04:12 am by Zemat »
Logged
You too can help bring to life the RogueLife Project!

korora

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #1 on: August 27, 2008, 03:12:39 pm »

I like your ideas, but for the siege-death responses, you currently have a 'fight fire with fire' system.  I think this is ineffective; since the defense has the advantage of fortifications, the offense needs to counter the defensive strategy, not match it.

I'd rather see a system where they play more to strengths of different units, something like ranged > melee > sneaking > ranged.  This makes sense because the ranged units can shoot the melee with impunity, but the sneakers can get close to the ranged units without being seen and kill them that way, but the melee guys can detect the sneakers by touching them and kill them, etc. 

It shouldn't be 100%, though; getting killed one way should simply increase the chance of bringing the counter-unit next time.

Traps don't really fit in here that well, but I think that's a separate issue and have stated my opinions on trap overpoweredness in the current thread on the topic.

I like the squad pathfinding particularly, and had thoughts along similar lines recently.  To be specific, the leader should pathfind to the target and the squad-members should pathfind to the leader.  The leader would give the order to break ranks and charge at the appropriate time; until then, they would strictly follow unless they get shot or have poor discipline.
Logged
DFPaint, a cross-platform 'screenbuilder' utility

Zemat

  • Bay Watcher
  • Zemat, programmer, cancels coding: Too insane.
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #2 on: August 27, 2008, 03:17:34 pm »

Yeah you are right, dwarven melee should be countered with ranged weapons. And ranged dwarves should be countered with siege weapons. I don't know what use melee invaders would have other than humiliate defenseless dwarves (dwarves have no thief like unit to counter yet). Also, my justification of using melee units against melee units is that legendary shield users are almost invulnerable to arrows. Only wrestlers would have a good change against them.
« Last Edit: August 27, 2008, 03:22:36 pm by Zemat »
Logged
You too can help bring to life the RogueLife Project!

thepuska

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #3 on: August 27, 2008, 03:41:02 pm »

Or just use the pathfinding function already in the game. Empty space tiles should be given a higher cost, as would be tiles that need to be mined. Then cut down as many trees as is needed to build the floors or staircases.

You could also increase the cost of pathfinding through an area (note: not a tile) if lots of goblins die in the area. Especially if they burn to death or suffocate.
Logged

Dae

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #4 on: August 27, 2008, 05:54:56 pm »

I doesn't really matter how much invading pathfinding code would be, because i think it should be done before the attack, when siegers appears.
Think of it as how the battleplan was made : if it doesn't work, you can't find a new one there, you have to retreat. Depending upon the siegers cleverness (their leader's one), several battleplans could be made.

If you want to enhance siegers AI by adpatability and learning from previous sieges, you can't just rely on how to have less losses. You have to think towards how to be more effective, meaning how much losses you inflincted to the enemy, take into account whether they were civilians, melee or ranged fighters, and how you killed them. More, high-skilled warriors killed should have a special treatment.
There would also need to keep how many buildings were destroyed, and how much value they represented.
Keeping track of how much of the battleplan worked and what screwed it up would help too.

Now with this said, organisation needs to be improved. Goblins fit their duty currently, but it isn't of any fun.
Siegers could be organised as squads, each having goals sorted by priority.

So there would be a 4-5 unit squad around a thief that would have for first mission to protect the latter. They would fight every melee fighter that comes close and use their shields to enhance the thief's protection from arrows.

Battleplans would have random points related to the leader's intelligence and military skills, acting as bonus. Then these points could be spent on different strategies, formations etc, each costing more points the more complex and organisation needing.

There also needs a more complex behaviour when winning the battle. If siegers haven't had losses for a certain time, while your losses keep on growing, they should consider themselves winners and start rampage, siezing food, drinks and everything valuable. Battleplan would be considered successful then.

Also, note that you fortress hasn't necesarily crumbled to its end then. Some have already built panic rooms. With enough luck, one could lose the battle, let siegers in, lock every civilian in the panic room, hold for a few years (now this would make an awesome story), train new militarians while living on kitten meat and undergound water and finally repel the enemy.
Logged

Mephansteras

  • Bay Watcher
  • Forger of Civilizations
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #5 on: August 27, 2008, 07:52:36 pm »

I'd also like to see invading groups have goals. Even better if they're based around the reason for the war. Obviously, a lot of this depends on the Caravan and County arcs being done. But I'm thinking long term. And goals could be randomly determined until the the background stuff needed for real reasons is in.


Here are some possibilities:

1) Conquest: Your basic run in, kill a whole bunch (maybe all) and take over the site. Should be done primarily for military or economic reasons. Say, protecting your caravans. Or maybe taking over a region with large gold deposites.

2) Raid: Very good for early fort attacks. The goal is for every attacker to run in and grab something of value. The focus might be on food and livestock, valuables, or even raw materials. Raiders can also make demands. This allows a weak fort to give up stuff in exchange for not risking any lives. Raiders bringing pack animals would help, as would better stack handling and bags that can hold stuff of different types. So you could have a goblin raider hit your trade depot and grab a bunch of gems and goblets, stuff them in a sack, and run off. Slave raids are another possibility here.

3) Retribution: The focus of the raid is very specific. Kill an individual, destroy a building, etc. Maybe the Elves are mad because you killed their liason. They return with an army and demand that the fortress leader be handed over for justice. If you refuse, they attack with the goal of getting to your leader and killing/capturing him. Or perhaps you sized a bunch of goods, so the Humans come back and destroy your trade depot, a bridge, maybe burn any outdoor fields they can find. Something to hurt you economically and pay you back for the wrong you did.
Logged
Civilization Forge Mod v2.80: Adding in new races, equipment, animals, plants, metals, etc. Now with Alchemy and Libraries! Variety to spice up DF! (For DF 0.34.10)
Come play Mafia with us!
"Let us maintain our chill composure." - Toady One

Techhead

  • Bay Watcher
  • Former Minister of Technological Heads
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #6 on: August 27, 2008, 08:47:52 pm »

Heh.
Every goblin death in a square adds 2 to its movement cost for goblins.
Of course, a 5-square route will take forever before the goblins decide to take the 50-square back door.
Logged
Engineering Dwarves' unfortunate demises since '08
WHAT?  WE DEMAND OUR FREE THINGS NOW DESPITE THE HARDSHIPS IT MAY CAUSE IN YOUR LIFE
It's like you're all trying to outdo each other in sheer useless pedantry.

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: Algorithmic suggestions to improve sieges.
« Reply #7 on: August 28, 2008, 12:41:37 am »

Goblins should not just up and leave if there is no access to a fortress.

In real life sieges often lasted until the city ran out of supplies and had to try to fight their way out, or an allied army could be brought to bear from outside to route the siege.

I would however like to see sieges result in a lot of schorched earth. The goblins should level your forests (to build temporary walls to provide cover vs siege engines, to bridge difficult terrain and finally to build their own siege engines to break down your defenses). They should also gather all the surface herbs in cases where they have to wait you out (allowing them to stay on the field a little longer before hunger sets in). Meanwhile they disrupt your trade and prevent you from receiving supplies. And finally to burn everything when they do finally decide to leave.

A siege need not kill a single dwarf in violence to cause significant damage to a fortress.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Jackrabbit

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #8 on: August 28, 2008, 12:49:50 am »

most are great ideas but

  • I dont want the siege to stop after killing the leader. it should be a random chance that the goblins would run
  • building a bridge over the moat is a little weird as bridges require planning and all. there should be siege ladders and those portable bridges. which they bring next time if they encounter a moat this time (like you said)

other than that good ideas!
Logged

Zemat

  • Bay Watcher
  • Zemat, programmer, cancels coding: Too insane.
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #9 on: August 28, 2008, 01:50:34 am »

Goblins should not just up and leave if there is no access to a fortress.

In real life sieges often lasted until the city ran out of supplies and had to try to fight their way out, or an allied army could be brought to bear from outside to route the siege.

I would however like to see sieges result in a lot of schorched earth. The goblins should level your forests (to build temporary walls to provide cover vs siege engines, to bridge difficult terrain and finally to build their own siege engines to break down your defenses). They should also gather all the surface herbs in cases where they have to wait you out (allowing them to stay on the field a little longer before hunger sets in). Meanwhile they disrupt your trade and prevent you from receiving supplies. And finally to burn everything when they do finally decide to leave.

A siege need not kill a single dwarf in violence to cause significant damage to a fortress.

I agree with your sentiments. Still what I don't really want to happen is that besiegers end up lingering there outside doing nothing for too long. The fort could very well last for ages with zero outside contact without problems. That's why I suggested besiegers try to do anything possible to damage the fort's insides before giving up. That's where nuking the site comes in: Goblins, who are smart and wise enough to create fortresses and tunnels, should be able to create a doomsday mechanism to kill a fort like a lava pump directly above the fort entrance, or maybe rain fiery death with !!arrows!! and balls of fire thrown from catapults. In the end, if they give up too soon because they couldn't find a way to penetrate it doesn't mean they will never comeback. They just made a strategic retreat and will comeback with some way to bring the fort down for good.

I dont want the siege to stop after killing the leader. it should be a random chance that the goblins would run

When I was talking about leaders I didn't refer to the siege leader but to squad leaders. If a squad leader is killed then his/her squad members should retreat after a while but maybe not completely. They could end up joining another squad or regroup under a new leader appointed during the battle by the main leader. If the main leader is killed any other squad leader could take the mantle of the siege if he/she has good leadership skills. Otherwise they could all end up retreating.

building a bridge over the moat is a little weird as bridges require planning and all. there should be siege ladders and those portable bridges. which they bring next time if they encounter a moat this time (like you said)

Lots of instances of real historic sieges required heavy engineering which included building counter-fortifications, channel-crossing bridges and even ship building. See for example the Siege of Antwerp. It lasted for a year with the Spanish (besiegers) building forts around the city to encircle it and a pontoon bridge (also fortified) to cross the estuary.
« Last Edit: August 28, 2008, 01:58:04 am by Zemat »
Logged
You too can help bring to life the RogueLife Project!

thepuska

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #10 on: August 28, 2008, 03:02:14 am »

Heh.
Every goblin death in a square adds 2 to its movement cost for goblins.
Of course, a 5-square route will take forever before the goblins decide to take the 50-square back door.

If you had a multiple tiles wide trapped entrance, this would lead them to spring every single one of the traps while trying to dodge the traps that had been previously sprung. I don't know if that'd be good or bad.

I agree with your sentiments. Still what I don't really want to happen is that besiegers end up lingering there outside doing nothing for too long. The fort could very well last for ages with zero outside contact without problems. That's why I suggested besiegers try to do anything possible to damage the fort's insides before giving up. That's where nuking the site comes in: Goblins, who are smart and wise enough to create fortresses and tunnels, should be able to create a doomsday mechanism to kill a fort like a lava pump directly above the fort entrance, or maybe rain fiery death with !!arrows!! and balls of fire thrown from catapults. In the end, if they give up too soon because they couldn't find a way to penetrate it doesn't mean they will never comeback. They just made a strategic retreat and will comeback with some way to bring the fort down for good.

All the goblins would need to do to destroy a fort is leave a burning cave spider silk sock right outside the entrance.
« Last Edit: August 28, 2008, 03:15:09 am by thepuska »
Logged

Techhead

  • Bay Watcher
  • Former Minister of Technological Heads
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #11 on: August 28, 2008, 06:07:23 am »

"Goblin Sapper"
A Dwarven prisoner is decked in full GCS silk, lit on fire, and tossed  through the traps.
Brilliant!
Logged
Engineering Dwarves' unfortunate demises since '08
WHAT?  WE DEMAND OUR FREE THINGS NOW DESPITE THE HARDSHIPS IT MAY CAUSE IN YOUR LIFE
It's like you're all trying to outdo each other in sheer useless pedantry.

Gauteamus

  • Bay Watcher
  • Ignitur!
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #12 on: August 28, 2008, 07:37:09 am »

This is a very interesting topic, but I must confess I haven't read the whole thread yet (intend to come back to it though). For now I will just pop in with a maybe controversial idea:

After having defeated a siege, the player gets the option somehow to supply the AI with information as to what went terribly wrong. This may happen through entries in an init file, through an ingame interface or elsehow. Of course you may as a player choose to skip giving feedback to the siege AI, letting it work out a, maybe poorer, strategy on its own.

I may be wrong, but to me it seems pretty impossible (even though Toady may make it work) to have an AI that recognizes e.g the Degrinchinator as a trap, and how it should be circumvented.

One very quick suggestion as to how I envision an init file may look (obviously I haven't put alot of thought into this):

[SIEGE_AI]
   [OBSTACLES]
      [RANGED_UNITS]
      [FORT_IMPENETRABLE]
      [CUSTOM_TRAP:76:34:5]
         [BYPASS:78:38:8]  %% every deathstar has a laundry chute, self destruct button or   trigging lever that may be blocked
   [WEAK_SPOTS]
      [126:23:7]  %% coordinates of entrypoint, food/water supply, unprotected wealth etc.
[/SIEGE_AI]

Of course with this one also gets the option of tricking the AI with wrong parameters, but come on, we are all mature players who wouldn't ruin our own single-player experience in such a low way!  ::)
« Last Edit: August 28, 2008, 07:47:35 am by Gauteamus »
Logged

thepuska

  • Bay Watcher
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #13 on: August 28, 2008, 07:55:09 am »

If you penalize areas where lots of goblins die with a higher cost to path through, they will start taking alternative routes into the fort.
Logged

Tormy

  • Bay Watcher
  • I shall not pass?
    • View Profile
Re: Algorithmic suggestions to improve sieges.
« Reply #14 on: August 28, 2008, 08:26:16 am »

most are great ideas but

  • I dont want the siege to stop after killing the leader. it should be a random chance that the goblins would run
  • building a bridge over the moat is a little weird as bridges require planning and all. there should be siege ladders and those portable bridges. which they bring next time if they encounter a moat this time (like you said)

other than that good ideas!

I agree that siegers should not leave after their leader is dead.
I dont agree with your second idea...Bridges over moats are must have, if we want to see better sieges. It must be very easy for the AI to construct bridges, we dont need any planning etc. in this case. Keep in mind, its AI afterall.

Also good post OP, "your ideas" have been suggested many times in the past years, but you summed it up nicely.  8)
Logged
Pages: [1] 2