.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   Mass flight bug - wrong script processing (http://forum.shrapnelgames.com/showthread.php?t=38174)

ano March 26th, 2008 03:01 PM

Mass flight bug - wrong script processing
 
I just didn't get it...
I had a huge army storming the castle defended by many mages and some troops and an A3 Rakhsharaja with 3 gems scripted to cast Mass Flight (spell requires A4 and 2 gems). It should have been an easy victory.
But he due to some reason decided to cast Arrow Fend and Storm Warriors and obviously things went in quite another way with much more losses.

Can anyone explain this? Maybe there're some bugs with this spell?

K March 26th, 2008 03:37 PM

Re: Mass flight issue
 
Check the file.

If there was a Storm going on, then flight wouldn't have worked, so the AI may have decided not to cast it.

Also, the AI prefers a buff for round 1, and it may not consider Mass Flight a buff.

Baalz March 26th, 2008 03:45 PM

Re: Mass flight issue
 
This can be one of the more frustrating things about the spell casting AI, it sometimes decides to override your "suggestions" regarding what spells to cast. Most of the time this can be a good thing, it keeps you from blowing a bunch of gems if an enemy scout attacks your army, or shooting lighting bolts at a lighting immune guy. Sometimes though, it seems like the AI's thought process goes like this:
This battle is easy, no need to cast mass flight, I'll save the gems
Hmmmm, no script, let me see what I should cast...
Wow, I've got some gems, I'll cast arrow fend!

This is one of the more frustrating things in dominions IMO.

thejeff March 26th, 2008 03:55 PM

Re: Mass flight issue
 
Rerun the battle with debug on, see what the log says about the casting decision.

Takes a little work to interpret, but can be helpful...

ano March 26th, 2008 03:56 PM

Re: Mass flight issue
 
I'll check it at home with debug options, probably with all those priorities displayed.
Yes, it's really frustrating, but if AI decided not to cast Mass Flight at this situation, I really can't imagine the situation when it would cast it. Two big armies (about 1300 units) were at the different sides of the walls and it was the prefect situation to cast it, but I've got Arrow Fend instead.
Did you successfully cast it at all?

ano March 26th, 2008 06:08 PM

Re: Mass flight issue
 
This is what I found there (extracts):
Quote:

com Aksa(A) cast spell (favspell Mass Flight) (mayusegems 1)
est. choices 59
spellscore, Arrow Fend score 220322 (boost 91 scorat 262128)
Eval: Arrow Fend score 179123 (fat 33)
comp_castspell: eval Arrow Fend result 179123
best spell so far Arrow Fend (score179123)
spellscore, Mass Flight score 873 (boost 92 scorat 1023)
Spell punished for excessive fatigue 459 -> 153
Eval: Mass Flight score 153 (fat 100)
comp_castspell: eval Mass Flight result 153
looser spell Mass Flight (score 100153)

SO!
The spell is punished for excessive fatigue! And thus Arrow Fend was definitely a better choice...
I can't call this a bug, this is just a bad algorithm that costed me a half of my army (or even more). Actually, this either has to be changed or anyone planning to script some big battlefield spell will have to think about this algorithm and the fact that AI may find another *not so exhausting* spell instead of the one your whole strategy is based around.
Actually I think that scripted spells should never be be *punished for excessive fatigue*. If someone disagrees, let's discuss this.

ano March 26th, 2008 06:20 PM

Re: Mass flight issue
 
One more thing...
In this very case I could have given my raksha an air booster but let's imagine the situation where someone is planning to cast something like mast flight (I don't mean exactly this spell as it is useless in the storm) with A2 mage and storm power. He will never be able to do this as the mage will always be *punished for excessive fatigue*.
If it is really so, I think, it's unacceptable.

Bananadine March 26th, 2008 09:53 PM

Re: Mass flight bug - wrong script processing
 
Would it have also helped to have given your ape four gems--2 for the spell cost, 1 for the level gain, and 1 more for fatigue reduction? That seems much more convenient than having to spend multiple turns forging an item and getting the mage to a lab to equip it, just so he will feel comfortable about casting one spell that he could have cast anyway if he weren't so worried about losing consciousness. And presumably it would work with Storm Power too.

I agree though, it's lame that such an obviously good spell choice would be overriden by a commander who should know better. The spells in this game are so varied and quirky, it seems very natural that big, special-effects like universal flight should get their own special priority determination methods (and maybe they do). For instance if Mass Flight was always given a priority boost when a large enemy army could be seen beyond a wall, then maybe that would overcome the excessive fatigue penalty. Or maybe the excessive fatigue penalty should be reduced when the friendly army is very large (thus meaning the tired-out mage won't be lying unconscious on a battlefield all by himself). And maybe it is, how would I know? http://forum.shrapnelgames.com/images/smilies/happy.gif

There are so many details that could go into their spell-scoring system--how interesting that code may be!

ano March 26th, 2008 10:11 PM

Re: Mass flight bug - wrong script processing
 
I could not give four gems because Raksha is level 3 air mage and thus can use only 3 gems per cast. So the only option is giving a booster item (Flight has obviously no sense during storm). This means (as I mentioned above) that this spell seems to be uncastable at all for a A3 mage without boosters once Arrow Fend is researched.
As for the battle mechanics, I just think that scripted spells should never be overridden because of "excessive fatigue". They still should be overridden if the spell cannot be cast or if the opponent army is *too weak* (I think, this is a separate discussion topic) but NOT in the case when everything is ok but the non-scripted spell which AI likes very much (Arrow fend in my case with 220322 score) is cast instead of scripted one just because it causes less fatigue. It makes no sense at all in my opinion.

NTJedi March 26th, 2008 10:13 PM

Re: Mass flight issue
 
Quote:

Baalz said:
Sometimes though, it seems like the AI's thought process goes like this:
This battle is easy, no need to cast mass flight, I'll save the gems
Hmmmm, no script, let me see what I should cast...
Wow, I've got some gems, I'll cast arrow fend!

This is one of the more frustrating things in dominions IMO.

These are two of my most annoying AI battlefield scenarios:

1) Front Mage Guard says, "Mage Leader we're winning and the troops of the enemy are now on the run."
Mage Leader says, "Let's see I'm done with my script orders... the enemy is retreating so I'll use my last earth gems and summon earth elementals!"
Front Mage Guard says, "Why waste those earth gems on elementals which won't even be able to fight???"
Mage Leader says, "Because using lots of gems gets me high."

=======================
=======================

2) Main Commander says, "Our troops are starting to fall... what shall we do Mage Leader?"
Mage Leader says, "Yikes you're right... I'm casting astral shield on myself and some other self help spells."
Main Commander responds, "This won't help our troops and it will make you fall asleep plus astral shield has almost no value for someone with low hitpoints such as yourself."
Mage Leader says, "It's all about me."

OmikronWarrior March 26th, 2008 10:33 PM

Re: Mass flight issue
 
I once gave a Grand Master (I think thats the MA Marignon unit) some fire gems to cast flamming arrows. After running out of script and while the opponent had routed, he used some remaining gems to summon a fire elemental, whose heat aura managed to kill the Grand Master.

As for the fatigue, I thought it was always capped at 199 no matter how much the calculated fatigue would be?

ano March 26th, 2008 10:41 PM

Re: Mass flight issue
 
Yes it is capped, but that is not an issue. Casting Mass Flight would cause 200 fatigue while casting Arrow Fend caused much less so AI decided to override the script.

As for your example with Grand Master, it has nothing to do with battle mechanics - just an unlucky situation) No bug there.

cleveland March 26th, 2008 11:43 PM

Re: Mass flight issue
 
Chief Bodyguard: “Well done, Nature Mage! Your last 5 spell choices were both clever and tactically relevant!”
Nature Mage: “Thank you, Loyal Bodyguard. But rational thought bores me…Touch of Madness!”
Bodyguards & nearby archers, in unison: “CHARGE!”
Nature Mage: “CHAR…”

Saulot March 27th, 2008 03:32 AM

Re: Mass flight issue
 
1 Attachment(s)
Quote:

NTJedi said:
Mage Leader says, "It's all about me."

Internet law demands I post this.

thejeff March 27th, 2008 08:48 AM

Re: Mass flight issue
 
Quote:

ano said:
This is what I found there (extracts):
Quote:

com Aksa(A) cast spell (favspell Mass Flight) (mayusegems 1)
est. choices 59
spellscore, Arrow Fend score 220322 (boost 91 scorat 262128)
Eval: Arrow Fend score 179123 (fat 33)
comp_castspell: eval Arrow Fend result 179123
best spell so far Arrow Fend (score179123)
spellscore, Mass Flight score 873 (boost 92 scorat 1023)
Spell punished for excessive fatigue 459 -> 153
Eval: Mass Flight score 153 (fat 100)
comp_castspell: eval Mass Flight result 153
looser spell Mass Flight (score 100153)



Actually, read it more closely. Mass Flight is being punished for extra fatigue, but that isn't what's stopping him from casting it. That just drops the score from 459 to 153, which combined with the 100,000 bonus for being scripted puts it at 100,153. That's below the 179,123 for Arrow Fend, so Arrow Fend is cast. It still would have been less if there wasn't the fatigue penalty: 100,459.

The real question is why is Arrow Fend rated so highly?

Endoperez March 27th, 2008 08:54 AM

Re: Mass flight issue
 
Quote:

ano said:
This is what I found there (extracts):
Quote:

comp_castspell: eval Arrow Fend result 179123
comp_castspell: eval Mass Flight result 153

The spell is punished for excessive fatigue! And thus Arrow Fend was definitely a better choice...

Actually, Arrow Fend got score of almost 180 000, while Mass Flight's total was 150 and even before fatigue reduction Mass Flight's score was under 1000... So there's something else going on in there. Perhaps Arrow Fend's score increases for every one of your units but Mass Flight's doesn't (i.e. Mass Flight isn't considered a buff, which someone already suggested), or perhaps every enemy archer on the field increases the chance of casting Arrow Fend, or perhaps castle's towers are considered more heavily than they should, but fatigue reduction wasn't relevant in this case.

ano March 27th, 2008 09:30 AM

Re: Mass flight issue
 
Yes, you're right. Problem is in extra high Arrow Fend score.
My army was about 800-900 units large (this may be the reason) but the only archers enemy had were two dozens of sprites (this doesn't seem to affect the score).
However I still think that scripted spells should never be punished for extra fatigue. And in order to avoid such situations scripted battlefield enchantments should never be overridden at all unless the enemy army is *too weak* and is not worth spending gems on it.
Btw... Does all this mean that my mage could cast nothing but Arrow Fend in this situation? It seems so...

ano March 27th, 2008 09:47 AM

Re: Mass flight issue
 
Btw... Does all this mean that my mage could cast nothing but Arrow Fend in this situation? It seems so...

thejeff March 27th, 2008 09:50 AM

Re: Mass flight issue
 
You get a 100,000 bonus for a spell being scripted, so take a look through the log. If there's anything else there above 80,000, he should be able to cast that.

ano March 27th, 2008 10:03 AM

Re: Mass flight issue
 
I know about that.
However, do you think that it is right and everything is ok with this algorithm?
Actually, my battle meant nothing and I have so huge potential that all these losses are nothing but a wasp bite, but there's a conceptual problem with this algorithm and I think it's worth modifying it in some way.

Bananadine March 27th, 2008 10:45 AM

Re: Mass flight bug - wrong script processing
 
Quote:

ano said:
I could not give four gems because Raksha is level 3 air mage and thus can use only 3 gems per cast.

Ah yes, thanks, I forgot that rule. A good thing to remember!

About the problem with the algorithm etc.: You keep saying scripted spells should never be ignored in this way, as if that rule should be patched onto the existing system on top of everything else. But it seems like they've already tried to work the rule into the spell priority system by giving some huge point bonus to scripted spells. So like others are saying, it might make more sense to say that the weird thing is the high Arrow Fend score.

However, due to the complexity of the spell system, this is surely not a problem that will respond well to addition of big new rules--it's a delicate, fussy tuning problem. There's probably no simple solution anybody's going to come up just by thinking about it; they've got to have access to the code and be able to twiddle with it until it seems to work in all reasonable situations. I'm a programmer, so my fantasy scenario would be to have a server someplace that runs a large number of test battles every time a developer tweaks the spell AI, and makes sure the mages in these battles all still make reasonable decisions. And then every time a thread like this comes up, they'd add another few test battles and then make little changes to the AI until all the tests pass again.

kasnavada March 27th, 2008 10:52 AM

Re: Mass flight bug - wrong script processing
 
An solution I've seen around for scripting is creating a player-defined spellbook for each caster so he can only cast a limited portion of list of spells you have researched, and doesn't use unwanted spells randomly.

Bananadine March 27th, 2008 11:56 AM

Re: Mass flight bug - wrong script processing
 
Quote:

kasnavada said:
An solution I've seen around for scripting is creating a player-defined spellbook for each caster so he can only cast a limited portion of list of spells you have researched, and doesn't use unwanted spells randomly.

How is this done?

kasnavada March 27th, 2008 12:02 PM

Re: Mass flight bug - wrong script processing
 
It doesn't currently exists in Dominions.

What it would be is for example : on the "details" screen of your unit, you would have a spellbook icon. In that spellbook you would have every spell you have researched and a possibility to :
- save the spellbook,
- load a saved spellbook,
- modify the current spellbook by setting whether it should be casted or not.

In a even more perfect world, you would have columns for each spellbook where you defined spells to use in different situations (even fight, assassination, easy fight, SC fight...), and possibility to set yourself the chance of spells to be cast (ie : 75% sermon of courage and 25% vine arrow for a dryad in early game).

That would be a dream for scripting.

thejeff March 27th, 2008 12:12 PM

Re: Mass flight bug - wrong script processing
 
And an absolute nightmare for micromanagement.

I'd rather have AI fixes.
And maybe a configurable blacklist of "never cast unscripted" spells. Used for your whole nation.

kasnavada March 27th, 2008 12:27 PM

Re: Mass flight bug - wrong script processing
 
The option to save and load spellbooks could have buttons so you can apply them to every units you control, or all of a specific kind of caster (all with 2N 1D), or all of a certain type (all vampires) to reduce micromanagement...

For me, a "configurable blacklist of "never cast unscripted" spells, used for your whole nation" is to be avoided, because I don't want my 2N mages to cast wine arrow, but I do want my 1N mages to do so. I want my 4N 2E casters to use nature spells, but 2E casters to use earth. A configurable blacklist for the whole nations doesn't let me do that, and is therefore in my opinion, not enough.

The solution I propose, however, doesn't prevent AI fixes. So don't choose one or the other, when you can do both.
http://forum.shrapnelgames.com/images/smilies/wink.gif

thejeff March 27th, 2008 01:03 PM

Re: Mass flight bug - wrong script processing
 
The thing is, to be competitive you'd have to use the individual spellbooks for almost every fight. And adjust it as you learned new spells.

The most common use for them wouldn't be to ban a few spells you didn't want, but to set a caster to spam one spell repeatedly after his script ran out.

Not optimizing spellbooks for every battle would soon be as effective as not bothering to script your mages for battle.

And if this huge change was ever put in, (Which it won't be. The devs have shown no interest in making such major interface changes.) you'd be able to workaround all the bugs in the spellcasting AI, so there'd be no pressure for fixes.


(And I know it was a typo, but I like the "wine arrow" spell. Damage and confusion.)

kasnavada March 27th, 2008 01:18 PM

Re: Mass flight bug - wrong script processing
 
Quote:

Not optimizing spellbooks for every battle would soon be as effective as not bothering to script your mages for battle.

I think that it would be as annoying to script your mage for every battle than changing the spellbooks... well, it's possible that it will never exist anyway, so...

The whole point of the spellbook idea, though, is to workaround all the bugs in the spellcasting AI, which in my opinion will never be resolved because there is no way that the AI could choose the spell that reflects best the strategy chosen by a player in a given circumstance.

thejeff March 27th, 2008 01:41 PM

Re: Mass flight bug - wrong script processing
 
Obviously the AI will never become perfect. It will never be "do what I want", especially when "do what I want" isn't the same as "do what I told you"
That's not a bug, that's just the nature of AI.

But what started this thread wasn't a complaint of the AI wasn't perfect, it was a specific case of the AI overriding the script, due to what looks like a massive overrating of Arrow Fend. There are similar issues with Astral Shield. These can be fixed as they're found, and may even trace back to the same root cause.

Which reminds me. Should this Arrow Fend issue go to the bug list?

As for the spellbooks, an easier solution would be to just extend the script or have a last action of Cast Specific Spell repeatedly. That's how the spellbooks would be used 90% of the time.
This has been suggested and shot down by the devs many times.

And, AFAIK, experienced MP players script all the mages they send into battle.

Kristoffer O March 27th, 2008 02:05 PM

Re: Mass flight issue
 
Quote:

ano said:
Yes, you're right. Problem is in extra high Arrow Fend score.
My army was about 800-900 units large (this may be the reason) but the only archers enemy had were two dozens of sprites (this doesn't seem to affect the score).
However I still think that scripted spells should never be punished for extra fatigue. And in order to avoid such situations scripted battlefield enchantments should never be overridden at all unless the enemy army is *too weak* and is not worth spending gems on it.
Btw... Does all this mean that my mage could cast nothing but Arrow Fend in this situation? It seems so...

Did you have many archers? It might be that the AI counts wrong and counts your archers instead of enemy archers and multiplies with your archerscore or something. Similar problems have caused problems in other spells (like stygian paths).

Jazzepi March 27th, 2008 02:10 PM

Re: Mass flight issue
 
This has been pretty frustrating for me.

I've had the exact same problem. Arrow fend instead of mass flight, especially in castles.

Personally I think any castle battle where you're storming should give a boost to mass flight.

Jazzepi

thejeff March 27th, 2008 02:22 PM

Re: Mass flight issue
 
Probably more effective to clamp down the abusive boost to Arrow Fend. Other wise you'll wind up storming a castle planning on Storm + Wrathful Skies and having your Storm overridden by Mass Flight because of the boost.

In other words, I'd much rather have the scripted behavior win, unless it just can't work, than try to tweak the AI to make better choices when it goes off script.

The simplest solution to all these problems may simply be to boost the favspell bonus. I wonder what the debug logs look like when the script includes spells that are useless (no valid target or no target in range) or battles that aren't worth wasting gems for.

ano March 27th, 2008 02:41 PM

Re: Mass flight issue
 
Quote:

Kristoffer O said:
Quote:

ano said:
Yes, you're right. Problem is in extra high Arrow Fend score.
My army was about 800-900 units large (this may be the reason) but the only archers enemy had were two dozens of sprites (this doesn't seem to affect the score).
However I still think that scripted spells should never be punished for extra fatigue. And in order to avoid such situations scripted battlefield enchantments should never be overridden at all unless the enemy army is *too weak* and is not worth spending gems on it.
Btw... Does all this mean that my mage could cast nothing but Arrow Fend in this situation? It seems so...

Did you have many archers? It might be that the AI counts wrong and counts your archers instead of enemy archers and multiplies with your archerscore or something. Similar problems have caused problems in other spells (like stygian paths).

About 70-80 atavis and markatas, probably. They were scripted to "attack closest" because I didn't need them and wanted to get soulless from Life After Death))

Quote:

thejeff said:
Probably more effective to clamp down the abusive boost to Arrow Fend. Other wise you'll wind up storming a castle planning on Storm + Wrathful Skies and having your Storm overridden by Mass Flight because of the boost.

In other words, I'd much rather have the scripted behavior win, unless it just can't work, than try to tweak the AI to make better choices when it goes off script.

Yes, I agree with it. That's the most real thing to be fixed

Edi March 27th, 2008 03:11 PM

Re: Mass flight issue
 
I'll add Arrow Fend to the buglist as purple so it won't be forgotten.

thejeff March 27th, 2008 03:32 PM

Re: Mass flight issue
 
Edi,
While you're at it, could you add in Astral Shield as a related issue?
I dumped some debug info on the Bug Discussion thread here

Edi March 27th, 2008 03:51 PM

Re: Mass flight issue
 
Done. Looks like I screwed up adding the Arrow Fend, so I added it again and the Astral Shield as well.

vfb March 27th, 2008 08:40 PM

Re: Mass flight issue
 
As a temporary workaround, if you can spare another A3 caster and a gem (or A2+2A), you could script an Arrow Fend before your Mass Flight.

Seve82 March 28th, 2008 10:21 AM

Re: Mass flight issue
 
I think that having both in castle storms is worthwhile. As would be to cast all available boost spells.

ano March 28th, 2008 12:21 PM

Re: Mass flight issue
 
How do you imagine flying during storm?)

moderation March 28th, 2008 10:11 PM

Battle Simulation
 
I have been thinking that it would be nice to have a "Battle Simulation" that you could enter just to see if the spells that you have scripted will actually be cast. Not sure if this wish would be granted, but it sounds like it would be helpful here.

vfb March 29th, 2008 06:22 AM

Re: Battle Simulation
 
Battle Simulator:

http://www.shrapnelcommunity.com/thr...?Number=471188

Use with easyspell.dm or debug.dm for spell access without waiting around for research.

You'll need to read the map modding PDF to set up the units/nations you want to test.


All times are GMT -4. The time now is 12:49 AM.

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