.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   Wishlist: Battle AI hooks (http://forum.shrapnelgames.com/showthread.php?t=46395)

WraithLord September 28th, 2010 09:23 AM

Battle AI hooks
 
AI hooks

I think no explanations are required re. how poor is the battle AI (and AI in general…).
Some notable examples:
- Mages refusing to cast scripted key winning spells
- Mages casting utter rubbish, like spamming protection on some militia instead of sleep to fatigue SCs, casting encase in ice million times on units already encased etc.
- Big formations just clog instead of spread thus dying slowly to a few SCs

It’s also well known that IW would never improve the AI but what if they were to do this relatively small effort to install hooks into their battle AI source code so that we could mod the AI. I’ll explain what I have in mind by way of example, (changed pseudo code in bold font):
- New mod command: #prioritize_spell_2_cast_hook $DOM_INSTALL_HOME/mods/ prioritize_spell_2_cast_hook.py
- In the belly of the source code leviathan where lies the code to decide which spell to cast, perhaps something like:
o Get list of targets
o Get list of available spells
o If isDefined(prioritize_spell_2_cast_hook ) then call prioritize_spell_2_cast_hook else Rank spells
o Sort ranked spells
o dequeue spell from list of spells

Motivation:
- Make battles more interesting
- Make mages vs. SCs more viable. right now the SCs take full advantage of the 5 slot script. The AI likes to buff so they'll always manage to buff while mages are at mercy of the AI
- Rarely researched/used spells will become more important/frequent
- Allow us to mod cool stuff like: black list spells and more

Opinions?

Hadrian_II September 28th, 2010 03:16 PM

Re: Battle AI hooks
 
yes please

Grand Stone September 29th, 2010 05:37 PM

Re: Battle AI hooks
 
This game has a lot of different units rules etc. and a lot of these rules are fun etc. But I allways feel like, well, it dosn't matter what I do as long as I have some kind of strattegy. I play mostly versus the AI, but often it seems to play very little role which AI i'm playing against. I useually find some of okish units, mass them out, and go hunting. Thats my style of play. But it seems that often that it doesn't matter what you do. Ok, flaming arrows and lots of archers is fun. But, all in all I actually think that to many units are too alike.


The game would have been way more interseting if the detalied description of each unit had more importance. And I think a slightly better AI in combat is part of the trick to making combat more interesting. On the top of my list, and an easy fix is to order my (and the AI) mages to cast more evocations spells!!! KILL, KILL, KILL...

Slobby September 29th, 2010 06:26 PM

Re: Battle AI hooks
 
It would be awesome if the 'hooks' could be set up differently for each type of mage in the game, so that each mage would bring something different to the table depending on what has been researched.

For example assuming both paralyze and soul slay are researched, set it up so that guru's of kailasa etc prefer to cast paralyze while the illithids of r'lyeh prefer to cast soul slay.

Complicated and probably not going to happen but it would be fun. :)

Gandalf Parker September 30th, 2010 09:59 AM

Re: Battle AI hooks
 
Kudos to WraithLord. This is one of the few times that Ive seen a suggestion like this where the person ACTUALLY seems to have a grasp on what the AI does before making their suggestion. The AI does go thru an extensive thinking process which anyone can look at (in a debug log). Instead of just a general desire to make the AI "smarter" (which when pressed tends toward a huge amount of IF statements for every possible nation/enemy/strategy) WaithLord has laid out a small fix which might actually be easy to do

One note though before anyone gets their hopes too high....
Even if such a change were made, it would most likely come in the form of an added "suggestion" from the pretender. Its not likely to go in as an absolute that you can count on. Probably something more like an added plus or minus to the priority list. Im not sure that an absolute would be considered appropriate for this game by the devs. They dont seem to regret the quirky AI.

If you want an absolute, then your best bet is to look toward some of the mods that remove the spell from consideration or make it more expensive. But I do think this change would be a good one

WraithLord September 30th, 2010 11:50 AM

Re: Battle AI hooks
 
Thanks GP! I like your "treat it as suggestion" idea. It can work out great :)

Oh & I neglected to mention that some sort of consistent, generic API would be required for bridging between the game and the hook. For example dictionaries and maps are trivial in python so the hook (python code) can expect some kind of Context structure passed to it that contains all the dictionaries, maps and lists that form the basis for the spell AI code thinking process. I imagine IW already has such infrastructure in place (in C code).

Last, I have programmed such hooks (from both ends) for big commercial apps and they were always one of the customer's favorite features. If planned correctly, with foresight of future needs, they make the product that much more flexible and long lived.

Gandalf Parker September 30th, 2010 01:19 PM

Re: Battle AI hooks
 
Hmmm that would be great but I think it just shifted from simple to involved.

Johan would be more likely to create a typing window to tell it a spell and a slider to affect it. Or cut-n-paste the in-game code for assigning a spell on the commanders script commands, into a new command for degrading a spell. An interface to some other external language I dont see as likely.

If it did happen Id expect something more DIY than exporting the AIs thinking. The list of spells we can provide and just a setting of something like Flight -10.

The debug file could be used to try and figure out what change you want to assign if you want to do something like move a specific spell to be slightly higher or lower than another specific spell.

WraithLord September 30th, 2010 05:09 PM

Re: Battle AI hooks
 
Quote:

Originally Posted by Gandalf Parker (Post 759636)
Hmmm that would be great but I think it just shifted from simple to involved.

Johan would be more likely to create a typing window to tell it a spell and a slider to affect it. Or cut-n-paste the in-game code for assigning a spell on the commanders script commands, into a new command for degrading a spell. An interface to some other external language I dont see as likely.
...

Those two options you just mentioned sound great. Do you think there's any chance to see this happen?- It would have a really big positive impact on the game.

fantasma October 4th, 2010 11:22 AM

Re: Battle AI hooks
 
If I look at the debug, it uses a points system to decide what to use, so a modcommand #sspellpriority that adds a fixed bonus is probably very easy as the decision making is not changed in nature. A #prioritypertarget that scales with the number of effects only slightly more complicated, I guess, since there is already some code that takes into consideration the effect a spell has.

Then the modder community can assign priorities to spells and the devs are spared the work to balance things out. Was not there a while ago a thread by Kristoffer asking which spells are used too much/too little? So there already are - hard coded - values like these, it seems.

WraithLord October 4th, 2010 12:31 PM

Re: Battle AI hooks
 
good idea.

I encourage all who stumble unto this thread to list the spells they think are used too little/much.

Another aspect that needs to be addressed is spells that should not be repeated if desired affect was already achieved, i.e. entangle or encase when target is already entangled/encased. The AI can spam repeat those indefinitely targeting that one SC while the other SC/s would slowly butcher all your mages.

edit: another caveat of this suggestion is that it doesn't take into acct the circumstances. i.e a whole different set of spells are required when the mage is on:
a- support role (i.e. please buff my soldiers)
b- mass kill (i.e. fireball those militias)
c- eliminate elites (i.e. put that SC to sleep/charm/frozen heart etc)

Muse October 4th, 2010 01:07 PM

Re: Battle AI hooks
 
Quote:

Originally Posted by WraithLord (Post 759902)
edit: another caveat of this suggestion is that it doesn't take into acct the circumstances. i.e a whole different set of spells are required when the mage is on:
a- support role (i.e. please buff my soldiers)
b- mass kill (i.e. fireball those militias)
c- eliminate elites (i.e. put that SC to sleep/charm/frozen heart etc)

It may be possible to assign a category to each spell, then utilize the current script of the mage to determine which category the mage is expected to cast post-script.
Perhaps the category of the last spell scripted is given higher priority weight.

Though, this does run the risk of reducing the delicious quirkiness of the AI-- it may be useful to add an On/Off toggle, default to Off, for such a feature. Thus modders can control the 'Obedience Level' of a particular mage.

WraithLord October 4th, 2010 01:13 PM

Re: Battle AI hooks
 
yes, or just add a sixth slot to script with role, something like:
spell1,...,spell5,anti-SC
or
spell1,...,spell5,buffer
etc.

Muse October 4th, 2010 01:24 PM

Re: Battle AI hooks
 
Quote:

Originally Posted by WraithLord (Post 759912)
yes, or just add a sixth slot to script with role, something like:
spell1,...,spell5,anti-SC
or
spell1,...,spell5,buffer
etc.

I'm uncertain-- there is a finesse to positioning, equipping, and scripting mages to gain the desired effect.
An overt behavior-directing addition would take a bit of the cleverness out of it. (And a significant portion of the entertaining 'AI Manipulation' skill requirement.)

A larger project that may preserve such an element would most likely involve: multiple categories per spell, algorithm for determining weights from script, mage-personality modifier.
As a side note: While 'mage personalities' may be somewhat thematic, they may also serve to 'lock' a particular faction into playing a certain way, reducing tactical diversity.

Dominions has an appeal partially stemming from the semi-organic unfolding of battle events due to the complex AI structure.
A good bit of fun is had from SP testing, in chaos theory fashion, to find the most optimal starting arrangement.

Gandalf Parker October 4th, 2010 03:01 PM

Re: Battle AI hooks
 
The problem with assigning roles is that there would never be agreement on it. And to get it totally good for most of the players would involve way too long a list of IF statements. The hosting would take forever.

Even now, the AIs recognition of SCs is continually questioned (the AI sending gods to war and to the arena)

WraithLord October 4th, 2010 05:22 PM

Re: Battle AI hooks
 
I think the AI is clueless when it comes to SCs. It doesn't recognize them, it can't build, equip or script them and its certainly unable to counter them. SCs would have been seriosly toned down as well as MM hell of nurturing them (equipment, scripting etc) if the (friendly) AI had a clue what they are and how to counter them (by making sure your mages cast the anti-SC spells and not some junk that fatigues them until they pass out).

Even if you manually script a bunch of N mages to charmX5 and face the enemy's SC on holdX5 (out of range) you're likely to lose all your mages due to that limitation of the AI. In-fact however you'd script your mages you'll most likely lose them in said scenario.

Gandalf Parker October 4th, 2010 06:21 PM

Re: Battle AI hooks
 
Its not clueless. Not great, but not clueless.
The computer players common complaint "sending god sto war and arena" is definitely mitigated by not giving it an SC god.

The AI for both player and computer, does make decisions based on who its combating despite the complaints. But recognitions are general such as scout, infantry, cavalry, archer, mage, priest, assassin, seducer, thug, SC. There wasnt room for tons of IF statements defining things further. Most of the complaints about what the AI casts, purchases, etc are based on wanting IF's

The problem there is that hosting would take a day. Which is something I voted for.

WraithLord October 5th, 2010 02:54 AM

Re: Battle AI hooks
 
The source code is in C or C++ right?- If so, there are optimizations for compound IF statements that the compiler can do when writing the assembly code. Also, IIRC the dev can "help" the compiler optimize by keeping to certain forms. I don't recall the details as my course on this was 12 years ago and I'm not doing this as common practice.

Anyway, lots of IFs shouldn't have such an impact on performance. It's usually IO and blocking threads that kill performance - both not relevant to turn processing.

fantasma October 5th, 2010 04:39 AM

Re: Battle AI hooks
 
I doubt the AI uses a lot of ifs, it rather assigns priorities given circumstances and then takes the one with the best result.

Given that, whatever was suggested can be done by applying a high bonus to single target kill spells when facing one strong opponent. To a certain extent this appears to be implemented. The issue is finding the correct weighting. My suggestions for the two mod commands could address many problems.

Now, please, don't mix the tactical AI with the strategic AI (the one that does the turns for AI players), since they don't have much to do with each other. The AI is not aware of a concept like thug or SC. He does not try to optimise a build for MR, protection or defense, give it AOE attacks and necessary resistances while trying to stay economic. This part is simply missing in the AI code, unfortunately, As is the contrary, how to specifically create a task force to deal with deliberate opponents. Now, this is a completely different cup of tea, where even many human players struggle, and is far from trivial to implement at this stage of development.

WraithLord October 5th, 2010 08:33 AM

Re: Battle AI hooks
 
I've seen little evidence to suggest that the tactical AI is any better than the strat. AI when it comes to thugs and SCs.
The tact. AI doesn't know to script and deploy them so much so as it doen't know what spells to cast in order to stop them.

Now, I'm not looking for perfection here but you know the Pareto principle?- Some measure to let the AI or us (modders) have the means to make some rough improvements.

Example: plant these hooks I was talking about and expose them to us.
Example: Add mod commands for including categories/tags/weights to spells.
Example: Add to AI rough "behavioral" guidelines so you could script mages as I suggested.

fantasma October 5th, 2010 09:05 AM

Re: Battle AI hooks
 
Oh, sure, it would be nice to add the hooks, but I was trying to suggest something more close to the existing code to keep it realistic.

I do agree that the tactical AI could do better at finding specific weaknesses to exploit and not committing suicide with invulnerability in a poison environment, etc.

I am not so sure I like your AI behaviour, not so much for its usefulness but rather for flavour.

WraithLord October 5th, 2010 09:31 AM

Re: Battle AI hooks
 
Well I already said I like your suggestion as well :)

I'd be happy to see *any* improvement.

Bananadine October 10th, 2010 09:49 AM

Re: Battle AI hooks
 
Quote:

Originally Posted by WraithLord (Post 759967)
Example: Add mod commands for including categories/tags/weights to spells.

YES YES YES

Maybe there could be an even simpler version of this. Somewhere in the source code there are probably some numbers--just ordinary, typed-out integers that are fed into the spell-selection AI algorithms. Let the game optionally read each of these from a mod. This is probably easy. I don't care how old the code is or how much they hate changing it--even so, it's probably still easy! Right? Maybe it'd take a few hours to invent a new mod command for each parameter. It might be a hassle. But how could it be hard? Well, maybe it could be. There's probably some way in which it could be. But I bet it's not!

And if every spell's priority parameters are represented as raw numbers like this, then this one, allegedly easy change would solve a big bunch of the tactical AI problems. Well, maybe it's not that simple. Maybe there are special algorithms for every spell, rather than special integers. But still, those special algorithms probably have raw numbers in them somewhere that they could probably pretty easily be taught to read from a mod.

Or maybe it would actually be easier to add a new system ("add a new system", always the badge of doom in a suggestion for game changes) to let players just specify one new number per spell. Just one little multiplier that'd modify the spell's priority just before the "last moment" in the prioritizing algorithm. Like, if Decay (spell #639) is cast too much, and Horror Mark (#637) too much, and Prison of Fire (#657) too little, then you might put in your mod:

#modifyspellpriority 639 60
#modifyspellpriority 637 75
#modifyspellpriority 657 150

where the latter numbers are multipliers in the form of percentages. That would be awesome.

Quote:

Originally Posted by WraithLord (Post 759902)
I encourage all who stumble unto this thread to list the spells they think are used too little/much.

I claim that in general, spells that work against magic resistance are used too much, and extremely powerful death-and-disablement spells are used too much, while spells with a small, sure benefit are used too rarely. A demilich in a nation that has researched Disintegrate is sometimes weaker than a D2 mage in a nation that only knows Raise Skeletons, because of this. Raise Skeletons is sometimes much better than Disintegrate, and Drain Life is often also better, but the mage will usually choose Disintegrate anyway. A necromancer priest will try to banish enemy undead, even though they've been encased in lead, rather than casting frickin Wither Bones on them, even though Wither Bones is IRRESISTIBLE. Wither Bones and Dust to Dust are badly neglected. Fire mages cast Blindness, rather than Incinerate. Incinerate is badly neglected. Air mages cast Confusion, rather than Lightning. Confusion is sometimes great but Lightning is often better. Personal Regeneration is neglected by dying nature mages. And yeah there is too much encasement in ice.

Hmm... most of my notes there concern enemies with high magic resistance, and single, extremely powerful enemies. Yeah, the dreaded "new system" is probably needed. A modder probably can't fix all this stuff without being able to base spell priorities on enemy magic resistance and the strength of the strongest enemy target. A simple, universal modification to the priority of a single spell probably wouldn't be enough. But... it might still help a lot.

Alternatively, maybe just one "small" change that drops priority for a spell blockable by magic resistance when the target has high magic resistance would do the trick, in many of these cases. And then the Dust to Dust castings I covet would naturally emerge on their own. Take that Tartarians!

I like the idea of giving different personalities to different mages, also. I think that would add good complexity to the game, and not bad complexity. (By contrast, ideas that involve new ways of controlling mages, "Cast Supporting Spells" and "Cast Damaging Spells" commands and such, could easily add bad complexity to the player's experience.) But... "new system"

Gandalf Parker October 10th, 2010 11:27 AM

Re: Battle AI hooks
 
Spells that get used too much or too little tend to rely on things like this nation, this map size, these mods, early/mid/late game which makes a general change to the game for that purpose questionable.

BUT I have seen that in general, many of the "the crappy AI didnt do what I scripted" are often the use of Alteration (defensive) spells when Evocation (offensive) spells were scripted. Except for certain strategies involving specific spells, I find it helpful to not research Alteration until the point in the game where I might have magic-based thugs. This varies for everyone of course but researching Evoke ahead of Alter has saved me some frustration IMHO

So maybe looking at the spells in those two categories and comparing the priority might help.

Or, getting Johan to get the AI to maybe cast ONE Alteration spell instead of bunches (damn cowardly mages protecting themselves so much that they are worthless in the fight)

Bananadine October 10th, 2010 01:25 PM

Re: Battle AI hooks
 
Isn't it generally good for a mage that can easily cast Drain Life or Disintegrate, to choose Drain Life instead of Disintegrate when the target has 26 magic resistance? Supposing the target is non-nonliving and all. And surely Wither Bones is generally better than Banishment, when magic resistance is high and either would technically work.

I've been playing only LA Atlantis for a long while, and that heavily influences the selection of spells I get to see overused or underused. But the overuse and underuse I see seems to be unrelated to that nation, except of course insofar as the nation determine's the mages' skills. Any nation could have a Mound Fiend that stupidly tried to banish instead of withering bones.

Gandalf Parker October 10th, 2010 02:04 PM

Re: Battle AI hooks
 
But then we are back into the long list of IF's. What exists now is basically a "this is better than this" list. So you can move a spell up and down, but its not likely that you can move it up and down IF something is true. It has to be an all-the-time change

And even then, most people are bound to make suggestions they think are always better but would break some nations in AI play

Unless of course, one of the modding suggestions or scripting suggestions can be put into place so that a player can decide for themself in each game to rate a spell


All times are GMT -4. The time now is 07:54 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.