Threat avoidance

Discuss the future of Warzone 2100 with us.
Post Reply
Troman
Trained
Trained
Posts: 424
Joined: 12 Aug 2006, 15:40
Contact:

Threat avoidance

Post by Troman »

Don't know how about you, but I can't look at how AI trucks get killed each time they go for oil and when their route goes near my defnce lines, this behaviour looks rather dumb. While we can check if there's any threat at the destination point there's no way to influence the route AI units will take.

To fix this i've implemented some threat avoildance into the pathfinding, this is how it looks like:
http://user.supradigital.org/troman/ima ... ance_1.JPG
http://user.supradigital.org/troman/ima ... ance_2.JPG
http://user.supradigital.org/troman/ima ... ance_3.JPG

I think we could add new interface buttons: "direct route" and "avoid threat" or something similar. Direct route would work as usual while "avoid threat" would make units go around enemy units and structures.

Such a feature would be usefull for all non-military units, like trucks going outside to build something or scouts loking for enemy, heavily damaged units going for repair or just small combat units deep in the enemy territory.

There are some flaw though: it puts additional stress on the CPU (although I tried to keep it K.I.S.S.), there are pre-defined gateways between zones on the map, units have to go through them no matter what, sometimes coming neat enemy.
Once the route is precalculated it is not changed anymore, meaning that if there was a lone structure and the route was built around it and now the structure is gone for some reason units will still be routed around that place. This probably won't happen very often, but still worth mentioning. Same applies to units.

Now to the purpose of this topic: would that be usefull in the game? If yes, only multiplayer/skirmish or campaign/multiplayer/skirmish?
Sign Up for Beta-Testing:
?topic=1617.0
User avatar
lav_coyote25
Professional
Professional
Posts: 3434
Joined: 08 Aug 2006, 23:18

Re: Threat avoidance

Post by lav_coyote25 »

reminds me of the discussion that ChainsawMonkey and spikeles had.... ;)


Quote:
To make a "General Purpose Skirmish A.I." that poses a real challenge to players equivalent to playing against good human players on ANY Map is something of a "Holy Grail". Especially when you cannot "Spawn Reinforcements" and rely on "Canon Fodder" and "Ant Swarm" waves. Within those constraints such an A.I. would have to be    "Dynamically Adaptive Tactically".


The Quest For AI

The Above link takes you to the Pumpkin2 forums where there is an ongoing discussion on A.I. (no longer active)

ChainsawMonkey & Spikeles -  a very "old"  idea...
--------------------------------------------------------------------------------

Adaptive AI?
Was thinking about AI last night. So without further adieu, some ideas:


AI capabilities.


Let's take a Warzone AI for an example. Basically a WZ AI is 90% random, the other 10% covering general stuff that needs to be done like checking that it has all required buildings in the Required Buildings list (HQ, at least one factory etc). Warzone's AI is quite simplistic really, at least in comparison with later games, but it gets the job done. However, it get's it done by random chance, which is something I'd like to see change.
Here's a brief rundown of what a Warzone AI does throughout the course of a game, with notes on what should be happening instead (going from the pre-game loading sequence, I'll go into some thoughts about the pre-game menu another time):

*1 Player clicks ok to start the skirmish. Pre-game loading sequence initializes. At this point there are some things I want to see happening, I'll talk about that in a moment.


*2 Skirmish Starts. AI starts methodically checking it's triggers to see what it needs to do, including assigning it's trucks to building duties based on the Vital Structures list. Vital Structs = Oil, power, HQ, Factory and so on. As soon as first Factory is built, AI will randomly pick templates for units and start building, with trucks being build sporadically throughout.


*3 Continue checking triggers. Send out scouts (usually trucks for a start) to check for oil resources and cap them, and also scouting out the general area. The AI knows at all times exactly where the other AI's are as well as the human player (s).


*4 Check Triggers. Once the AI has built all vital structures it will start to concentrate more heavily on base defence as well as building additional structs such as factories. Also keeps track of research topics (again, randomly assigned). Once vtol tech has been reached it will build a vtol fac and proceed to start constructing vtols on a triggered basis.


*5 There are 3 triggers the AI is primarily interested in regards attacking - AttackStuffTr, and allOutAttackTr are the battle oriented ones. The first trigger will be set to a lower number such as 300, which means that every 30 seconds (10 WZ units = 1 second) the AI will harass another player with a small group of units. The second trigger will typically be set to 1500 or more and when triggered the AI will attack with a massed force. The other trigger (numAttackers) determines who the AI will attack. This is normally set to around 40, meaning that if the AI has less than 40 units it will harass an AI, if it has more than 40 units it will cause big trouble in the Player Base.


*6 Continue checking triggers, keep building base items and defences while attacking AI or player. As structures are destroyed, send out trucks to the dumbest locations possible to try and rebuild (bit of sarcasm there). If the enemy attacks using vtols, send out a truck to build an AA defence structure.


*7 Continue random research while attacking, defending etc ad infinitum until either victorious or defeated.
Now, as I mentioned above, the WZ AI is simplistic yet gets the job done, at least to a certain degree. But looking at the above, it is plain to see that there is no room for improvement, no room for an AI to grow throughout the course of a game. In other words, the AI is stuck using it's pre-defined triggers and can't adapt to new situations, or even recognize new situations.


Pumpkin did good with the tools they had available at the time, but in this day and age, we can do much better. So, moving on. I'll post the second part with my comments separately in a second post, so if anyone reads this, please refrain from posting anything until I'm done writing the second part, thanks :)
[Edited  by ChainsawMonkey]


Ok, so my thoughts on a real-time adaptive AI.

Looking above, we'll see that everything is done using timed triggers (at x time we should do this, at xx time we need to do this etc). Ok, for some stuff this is fine, but throughout the course of a game there are many different situations that a good AI should be able to take into consideration, like the layout of an opposing player's base - where is it most heavily defended? Where are his troops amassed? Is there a secret tunnel entrance I could use to arrive right in the middle of his base and cause wholesale carnage at minimal loss to my own troops? And so on.
Couple this use of triggers with an AI that has no regards for it's own troops as such and what do you get? Simple, you get a dumb AI. So how do we get around having dumb AI's to play against? We make them dynamic, ever-changing, adaptive
Right, so we want a dynamic AI, cool. But how do we achieve this? I think there are a lot of things we could implement that would give the AI the fighting chance it needs to actually outwit a human opponent. So I'll begin with the pre-game loading sequence:
Why have the AI solely based upon timed triggers? Probably because of limitations on computer hardware at the original time of release. Ok, so how can we get some more life into our AI? By giving it a personality. That's right, personality. Obviously not in the sense that the AI will open communications and start chatting in a pally fashion about what it did last weekend of course lol. But there is definitely room for an AI to have personality traits, such as likes and dislikes. So, we have the pre-game loading sequence. One of the things that could be generated at this time is the aforementioned personality traits for each active AI. Let's take favorite color as being a personality trait (referred to from now on as PT) for an example.
The game loads, assigning random PT's to each AI (incidentally the PT's would have some basis in Factions rather than being totally random). There are 3 AI's and yourself. AI#1 is assigned Blue as fave color, #2 Red, and #3 Green. Now let's say you decided to choose Red as your player color. Let's assume that you want to ally yourself with AI#1, who's fave color is Blue. Now, there would be less likelihood of this AI allying with you because his PT dictates that he likes Blue, so you'll quite probably be declined the offer of friendship and allied status. However, if you approached AI#2, his fave color is Red, so you'd stand a much better chance of gaining his favor.


Obviously that was an example in it's most primitive form, but I hope you understand what I'm trying to get across. PT's assigned right from the beginning of the game like this would instantly make each AI a unique customer with his own likes and dislikes based upon possibly dozens of variables including things like Faction (thanks go to Papa and Flamey for their work on the factions, since the idea of factions kind of led me to thinking about PT's), environment, even weather conditions and color preferences. There is a lot of scope here for making each AI unique.
Now I'll move onto Triggers, the mainstay of a Warzone AI. Triggers are good, they're simple and can be checked regularly by the AI with basically no overhead on the machine running the game. But triggers only go so far, as will be seen in any game against an AI in Warzone.
Triggers force the AI into doing things regardless of danger or whether there may be a better alternative.
So let's give the AI the ability to choose it's best course of action. Say an AI decides to attack another player's base. Rather than just charging in blindly with masses of troops and units (incidentally in a straight line that can be picked off one by one), it would send out a number of scout units (ALS style - ie Air Land and Sea) to the enemy base and check the layout of the base for weakness.
Now, the enemy base has, say, 3 entrances - one primary front entrance, a secondary side entrance, and a tertiary rear entrance that leads directly onto a mass of water. The AI would do a preliminary scan of defences on each entrance to the base and make a calculated choice on which entrance would be best to try and crack.
It looks at the front entrance - Not good, Rail and Gauss with Pulse lasers == heavy losses. So it discounts that entrance for the time being.
It checks the side entrance - looking better, some HPV and HCannon with a few Lancers == losses but statistically fewer than the front entrance.
Now it checks the rear entrance, by using a fast gunboat - minimal defences, maybe one or 2 Cannons and a couple of destroyers docked at a port == few losses and an easy attack route through open water.
Now it would depend on the particular forces the AI has available as to which it would choose in the end. The front is written off straight away as not being viable for the moment due to heavy casualties being predicted. So it looks instead at the other 2 options.

The side entrance is viable but what's this? The route to the side entrance goes right through a narrow valley, meaning possible heavy losses again due to not being able to mass an attack. Ok, that option is temporarily written off too.

So it's left with the water route. As luck would have it, the AI has a number of amphibious assault craft with troop carrying capacity. Looking at the available information it sees that a water based attack is the most viable option, using it's amphibious assault craft to ferry the main attack force right on to the enemy shoreline. It just needs to send in some destroyers to clear out the enemy vessels ahead of the main attack force. Decision made, all in the blink of an eye. However, that 'blink of an eye' would also be enough for you to mount a defence, if you've got your eyes open and see the scouts sniffing around your borders


Hopefully you'll see what I'm getting at here, with talks of adaptive AI. Let's say that in the above example the AI didn't have any Sea based units. It therefore automatically writes off that option as not being viable due to lack of appropriate units. So it goes back to the other 2 routes.


Now technically the second entrance is better since it has less high-tech devastating weaponry to contend with. However, this route leads through a valley, meaning a massed attack is out of the question. The AI might, therefore, decide to risk the losses at the main entrance, deciding that a massed attack will allow it to destroy the superior weapons at that entrance faster than it would be able to at the side entrance.

So you will see, the AI has made an informed decision based simply on the information it is given by it's scouts And you will also notice that the general layout of the land had a big hand in the final decision too.


Again, this option could have also been swayed by the AI's particular PT's. Say it has a faction specific PT that dictates that it will prefer to use Tracks over Water propulsion, that could have a big hand in the decision. Or that the faction specific PT dictates that the AI is particularly well suited to mountainous warfare, that could have swayed it in the direction of the Valley assault.


PT's could also affect how an AI lays out it's base. Say the AI has been assigned a PT that dictates it as being a defensive player - it would build it's base with primary targets in the best position for defence and build outwards from there, all the while increasing it's defensive capabilities.

An offensive player on the other hand would probably start off with factories near the front of the base for quick assault and worry about other stuff later.


PT's would also define how willing an AI is to take unnecessary risks. We all know how dumb the WZ AI is when it sends trucks right to your front door to build a derrick when you have 6 scourge hard points in the area lol. A headstrong PT combined with a cunning tactical PT could provide some interesting scenarios for example, it would be hard to gauge how it would react because the Headstrong aspect of it's character could send a rush of tanks unexpectedly right into the teeth of your defences to catch your attention, while the cunning tactical aspect could be moving additional troops around the side for a surprise attack while your busy at the main area of the attack.


As well as determining what PT's an AI starts with, I'd like to see research topics assigned at the beginning of a skirmish. The AI will be given a high level topic or possibly a number of topics right from the outset which they will then work towards getting in an efficient and organized manner (possibly dependant on PT's again). Thus, the AI will develop more of a personality as it strives to gain that particular level of tech, rather than aimlessly researching right through the available tech tree like Warzone AI does.


And to finish, just a brief note on visibility of terrain and enemies. It bugs me in Warzone that the AI's all start off pre-informed as to starting locations. Fair enough, you'll have some vague idea of where people are, but you shouldn't automatically know who occupies what location. Therefore I propose that the AI be given a blank map representing the playing area, with a fog of war that it has to explore in the same way as a human player (we might not use the fog of war I know, but I'm referring to the minimap rather than the actual playing area, essentially meaning the AI starts off as blind as the human player).

Well, that's it for the moment, I'll add stuff as I think of it. Hope that gives you something of an idea of how I'd like to see the AI develop for TWZ

ChainsawMonkey
A brief note on the menu system regarding AI's. There is talk of having customizable AI, well I think the Personality Traits system could very well cater for that too. It would be easy enough to set up a design screen with access to all the various PT's, allowing a mix and match approach to building a new AI. Also, we could release new PT's as plug-ins for the game, as well as people being able to write their own too. The ability to literally mix and match PT's to create a new AI would be great I think, since it would require no coding on the part of the user - he or she simply needs to build the AI by placing the initial PT building blocks Fantastic


Another brief note:
To avoid areas of high danger.. use a threat assessment map. eg. each tile given a threat rating based on units/structs near around it.. so a scouting unit for example will head into the areas (tiles) of least threat.. and the AI can determine the weakest flank to attack too. :) spikeles

as an add on.. we could have a special view mode (sort of like 'z' in WZ) that shows that in a color scheme.. getting from a green to dark red. - willis

Yep, threat assessment maps sound good too, thanks for that Spikeles, and the 'z' function is good too, but I'd like to see it utilized more than it was in warzone. As you mentioned Willis, a real-time threat AOE with red indicating the most dangerous area and green indicating safe areas. Nice. (ChainSawMonkey)

Ok here's a very simple graphical representation of the threat map in action. The red circles would represent the optimum firing range for the weapon emplacements, the yellow circles would be the maximum firing range and the green circles are safe zones where the weapon can't fire but a unit is still aware of the weapon's presence.

You'll see that the AI's preferred route takes it straight through the safe zones, avoiding any risk of being fired upon, but of course this would depend upon terrain - therefore giving the player more reason to really think about weapon structure placement in order to catch enemy units within the cross-fire of a number of emplacements, not to mention making life more difficult for scout units

[Edited  by ChainsawMonkey]

Ok here's a very simple graphical representation of the threat map in action. The red circles would represent the optimum firing range for the weapon emplacements, the yellow circles would be the maximum firing range and the green circles are safe zones where the weapon can't fire but a unit is still aware of the weapon's presence.
You'll see that the AI's preferred route takes it straight through the safe zones, avoiding any risk of being fired upon, but of course this would depend upon terrain - therefore giving the player more reason to really think about weapon structure placement in order to catch enemy units within the cross-fire of a number of emplacements, not to mention making life more difficult for scout units 

[Edited  by ChainsawMonkey]


color-danger is harder then we think..

brief example, in WZ t1 a machinegun could be considered dangerous... but how do you compare that to gauss cannon? or a viper unit vs. a dragon unit. How do we determine what's considered dangerous? i like your demo monk, n maybe only accounting for range could be a way to do figures.. but what happens when i spread out a lot (WZ example) of gauss cannon implants & scourge rocket towers... and on the side make a huge clump of mg bunkers? it'll think the gauss n scourge route is safer because its spaced out...and the units are tricked into going suicide - willis

Just some links:
It's also called "Influence mapping"
This is an entire thread on it:
http://www.gameai.com/influ.thread.html
and an applet for the same...
http://www.ccg.leeds.ac.uk/james/influence/
I'm full of usefull links. :) spikeles

The scourge towers will have a higher rating.. In the example all the things are the same "strength". In reality though a machine gun bunker will have a low value.. say 1.. and a scourge tower will have 8. So the values around the towers will be HIGHER and more dense then the bunkers. The bunkers will of course have a rating too. Just a lower one.
Also. Each unit will have to evaluate it's OWN threat map. Because a machine gun will do LOTS of damage to a wheeled viper but almost 0 to a dragon.
Also.. carry the idea a little further.. Imagine the enemy PLOTTING a course AROUND your air defence to take out your HQ... Just like they do in real life.. plotting courses around the SAM sites.. it can be achieved with threat maps! [Edited by Spikeles]

Attachments
aipreferedroute.jpg
Last edited by lav_coyote25 on 31 Oct 2006, 01:17, edited 1 time in total.
‎"to prepare for disaster is to invite it, to not prepare for disaster is a fools choice" -me (kim-lav_coyote25-metcalfe) - it used to be attributed to unknown - but adding the last bit , it now makes sense.
User avatar
C01eMaN
Trained
Trained
Posts: 58
Joined: 11 Aug 2006, 07:17
Location: UK
Contact:

Re: Threat avoidance

Post by C01eMaN »

Troman wrote: would that be usefull in the game? If yes, only multiplayer/skirmish or campaign/multiplayer/skirmish?
it would be good in multiplayer/skirmish in keep the campaign as it is...

what would be good is to have a commandline (e.g. warzone2100 --disablepathfinding ) to disable it for the users that have a poor cpu
Im Addicted To Warzone!!!!!!!
Troman
Trained
Trained
Posts: 424
Joined: 12 Aug 2006, 15:40
Contact:

Re: Threat avoidance

Post by Troman »

(I will have mercy with readers and won't quote Coyote's post.)

Nice theoretical discussion, I think I saw it someday already.
About the threat-assignment maps; I was playing with idea to add another radar view yesterday and guess what it was? Right.
Although I was thinking about adding it as a hidden future, for debug purposes, since I don't know how humans players would profit from it. We already have shift+tab and ctrl+tab which offer good overview of the map.

What I implemented today was the result of those musings, although it doesn't have much to do with threat assignment maps, but goes into that direction.

Threat assignment maps would be usefull for AI tactics, but WZ doesn't satisfy the necessary requirement for that yet. We simply don't have control over routing through scripts. We can't even eveluate how long a route from x1-y1 to x2-y2 will be. We don't have flocking behaviour, and until AI will give up ant tails there's no way we can implement any real combat tactics, unfortunately.
Last edited by Troman on 31 Oct 2006, 12:51, edited 1 time in total.
Sign Up for Beta-Testing:
?topic=1617.0
User avatar
Watermelon
Code contributor
Code contributor
Posts: 551
Joined: 08 Oct 2006, 09:37

Re: Threat avoidance

Post by Watermelon »

probably it's too costy for a RTS game,the threat 'map'(or navigation block with threat) needs to be updated every a few seconds to cope with the changes on map(newly built/destroyed structures).With a huge map like wz has(even the smallest map of wz > the biggest map of a fps game),that will cause brief pauses whenever it updates the threat map.
tasks postponed until the trunk is relatively stable again.
Troman
Trained
Trained
Posts: 424
Joined: 12 Aug 2006, 15:40
Contact:

Re: Threat avoidance

Post by Troman »

Watermelon wrote: probably it's too costy for a RTS game,the threat 'map'(or navigation block with threat) needs to be updated every a few seconds to cope with the changes on map(newly built/destroyed structures).With a huge map like wz has(even the smallest map of wz > the biggest map of a fps game),that will cause brief pauses whenever it updates the threat map.
If you had threat avoidance in mind, it doesn't depend on influence or threat maps.

As for influence maps being costy; I think if properly implemented they don't have to be costy. The biggest wz map is 250x250 in tiles units (higher resolution would not make sense anyway). But then again personally I have no plans on implementing influence maps, I might toy with it for AI debugging purposes and that's it, I don't see a need for it as a game feature.
Sign Up for Beta-Testing:
?topic=1617.0
Post Reply