As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
CoM II - Automatic Combat spellcasting

When automatic combat starts, each side is evaluated for their spellcasting ability in 6 categories, based on known spells.

Oneshotbuff
This is a special category that has the sum of the defined values of known combat global enchantments. This category influences the combat only once during turn 1 and can be of any amount. In general, assume each known combat global adds 2-9 to this value.

All remaining categories take the value of the best known spell in the category, ignoring all weaker spells, and range from 0 (no spells known) to 10 (best very rare).

Buff
Spells that help the unit survive.
Examples : Resist Magic, Mystic Surge, Invisibility.

Ranged Buff
Spells that help the army deal more ranged damage, usually by slowing down enemy units or increasing ranged attack power.
Example : Web, Entangle, Flame Blade, Mystic Surge, Construct Catapult

Direct Damage
Spells that damage enemy units or render them unable to defend against damage or fight back.
Examples : Lightning Bolt, Mystic Surge.
This is the only category where the best spell is rated 15, not 10. This is neccesary to preserve the balance between realms as Chaos doesn't really do anything else.

Curse
Spells that deal damage or weaken units by targeting their resistance.
Examples : Weakness, Possession, Massacre

Summon
Spells that give you new units or otherwise contribute to the hit points of your army directly.
Examples : Wild Boars, Healing, Construct Catapult

If you know every spell in one realm, you have this many total "levels" :
Life, Nature has 44
Sorcery has 51
Chaos has 49
Death has 52

I believe this does match the actual combat casting value of each realm well enough - Chaos, Death and Sorcery are powerful, while Life and Nature are good but somewhat less focused on combat spells than the other three.

Once these (and army stats) are calculated, combat starts.

The order of phases are
1. Defender spellcasting
2. Defender ranged (if applicable)
3. Defender melee (if applicable)
then the same order for the attacker, then repeat until one side dies.

We'll only focus on spellcasting at the moment.

First, the amount of MP used for the turn is determined. This is usually 40 for turn 1, 20 for each turn afterwards, or less if the wizard doesn't have more skill or mana remaining, but high casting skill wizards use 50 and 30 instead.

On turn 1, "oneshotbuff" takes effect. (remember, this will always use 40 or 50 MP unless the wizard has less)
This grants the army ("oneshotbuff level" * MP * 33 /400) percentage extra hit points.

Example 1 : the wizard knows only Prayer. Prayer is worth 7 levels.
(7*40*33) / 400 = 23% additional hp to the army.
Example 2 : the wizard knows Prayer, Mass Invisibility and Call Lighting for a sum of 7+8+8 = 23 levels.
(23*40*33) / 400 = 75% additional hp to the army.

Basically, each "oneshotbuff" level is worth 3.3% additional HP for the army unless the wizard cannot afford the initial 40 MP. (or it's worth 4.1% if their casting skill is 200 or more which allowed them to use 50 MP on this phase)

After this, on turn 1 as well as all other turns, all 5 remaining categories are applied - individually weak but we are basically pretending the AI casts 5 spells at the same time but each at 1/5 the "normal" power :

Buff adds ("buff level"*MP*/100) % HP.

For example level 5 at 20 MP would add 1% HP. (However, as long as the wizard has mana, they can use this every turn.)
At max level and max (30) MP spending this basically adds 3% HP per combat turn to the army. (which is as good as 15% if they had the ability to pick this category instead of requiring to use all 5 at equal weight.)

RangedBuff adds the exact same percentage (calculated from the rangedbuff level of course) but to all ranged attack powers in the stack instead.

Direct Damage deals ("direct damage level"*MP*12 /2000) magical ranged damage to the opposing army.

For example at level 7 (doom bolt) this deals 0.84 damage per 20 Mp spent.
(again, if this wasn't only the 1/5th of the casting available, we could be doing 4.2 damage per 20 MP but that feature does not exist yet.)

...this feels underpowered for a Doom Bolt as it's only 8 damage per 40 MP instead of 12. So let's try to look at another spell.

Fire Bolt is level 4, so it's 0.48 damage, or would be 2.25 at full power for 20 MP, 4.5 damage at 40 MP.
This feels even more underrated than Doom Bolt even if I pretend the enemy might have high armor (which is not part of the formula at all here.)

My mistake here is that I have in the code as comment "40 MP at max level is worth 12 damage" but that's just not right. Doom Bolt is worth 12 damage but Doom Bolt is level 7 not 10. (also this category doesn't even max at 10 anyway but we have to pretend it does otherwise the extra levels we game chaos have no meaning.)

...so to improve accuracy, this formula should change to "/1400" instead of "/2000" for accurate Doom Bolt but there is a catch. Doom Bolt has the worth damage per mana ratio in the game in exchange for consistency and ignoring armor.

So we should decide how much damage we want from direct damage spells, because this amount is too low.

For reference, Fire Bolt and Fire Ball are level 4 direct damage spells, Lightning Bolt is 6, Warp Lightning is level 8, Flame Strike is 12, Apocalypse is 15.

In real combat, Warp Lightning deals roughly 12 damage for 30 MP. That would put Lightning Bolt at 7.5 damage which isn't so far off, and Flame Strike at 36 which is a reasonable average. (9 units take much more but 1 unit takes much less)

So if we go with that then the improved formula should be
("direct damage level"*MP*12 /1200)


Curse category next which deals "Curse Level"*MP*(13-Enemy average resistance)/750.

Example : Petrify, enemy resistance of 7. Petrify counts as level 5.

Damage is (5*20*6)/750 = 0.8.

They would be 4 damage if it wasn't dividing up casting to 5 categories.
Well...not very good. I mean, for a 60% chance to kill an enemy unit, we assume that's worth 4 damage.

So let's try to look at this from a different angle. An average unit has about 15 HP.
Each 1 missing save modifier is 10% chance the unit dies, so 1.5 damage.
Out baseline is petrify which does this for 20 MP and is rated level 5.
So we want (5*20)/X = 1.5 which means X= 66.
Except, again, that's for the full casting power but we use only 1/5 of it, so 330, making the formula
"Curse Level"*MP*(13-Enemy average resistance)/330.

Finally, we have
Summonig
Which gives the army HP and Melee attack power equal to
"Summoning Level"*MP/1000 times the stats of a Wild Boar unit which is 15 HP and 720 Melee.

This has one problem - the melee formula was updated meanwhile.
Currently a Wild Boar would be 600*40*4 / 200 = 480 melee.

A bigger problem is, Wild Boars are not the pinnacle of summoning. They are what you get for level 10 but the Boar itself is categorized as a level 3 spell.

So this should correctly be "SummoningLevel"*MP/300 instead.

This should fix the inaccuracies in the formula and might show why stronger wizards had problems, as all three categories that contribute in a relevant way against ranged garrisons were underrated.

However, we probably still should design some sort of a ruleset that determines a percentage of casting power spent on each category instead of defaulting to using 205 on each.

For example, if my only combat spell is Fire Bolt and have 100 mana, then I won't do "I spend 20 MP on Fire Bolt, then I cannot use the rest because I need to save the other 80 MP for summoning and buffing spells but I don't have any", no, I would do "I cast Fire Bolt from all 100 MP".
While that's the most obvious mistake (spending on categories the wizard doesn't even have), I think we need more detail than that and spend higher on the categories that actually are more relevant for the current battle.
For example if we greatly outnumber the enemy army then using the buff category (to boost our advantage) or using one of the damage categories (to kill the enemy and end the combat faster, denying enemy casting to be relevant) are good tactics, while summoning is wasted MP (it gives much less than buffing by percentage). Another example, if the enemy has very high attack power but low hit points, then direct damage is great but buffing our own durability is bad. If they have high resistance then preferring direct damage spells over curse spells is a correct choice.

etc.... the part I'm not sure about is how to handle this. Unlike casting a spell in normal combat, here we aren't picking one best option but distribute a total of 100% between the 5 possible choices. It is valid to pick 0% but should be avoided as much as possible because dong so reduces the relevance of the AI obtaining new spells of those categories. At the same time, if we don't do enough weighting and stay close to the :use everything" then we get stuck with the current system where mana is spent on categories that don't help winning at all.
Reply

This is the current table of what spells contribute how much to which categories :

Nature

Web - RangedBuff 3
EarthToMud - RangedBuff 5
Entangle - Rangedbuff 10

Resist Elements - Buff 1
Regeneration - Buff 1
Elemental Armor - Buff 3
Iron Skin - Buff 7

Fairy Dust - Damage 1
Ice Bolt - Damage 3
Crack's Call - Damage 4

Petrify - Curse 5

Wild Boars - Summon 3
Construct Catapult  -Summon 4, Ranged Buff 4
Earth Elemental - Summon 10

Call Lightning - Initialbuff 8

total : 10 rangedbuff, 7 Buff, 4 Damage, 5 Curse, 10 Summon, 8 Initialbuff = 44

Sorcery

Resist Magic - Buff 2
Guardian Wind - Buff 3
Flight - Buff 3, Ranged buff 2
Magic Immunity - Buff 8
Invisibility - Buff 10

Stasis - Ranged Buff 7
Haste - Buff 7, Ranged buff 7

Phantom Warriors - Summon 1
Phantom Beast - Summon 5
Air Elemental - Summon 7

Aether Sparks - Damage 2
Psionic Blast - Damage 3
Dispelling Wave - Damage 4
Mind Storm - Damage 5

Confusion - Curse 4
Vertigo - Curse 3
Banish - Curse 4
Creature Binding - Curse 5

Blur - Initialbuff 4
Counter Magic - Initialbuff 5
MassInvisibility - Initialbuff 8

Total : 7 rangedbuff, 10 buff, 5 damage, 7 summon, 5 curse, 17 initialbuff = 51

Chaos

Flame Blade - Buff 3, Ranged buff 3
Immolation - Buff 4
Mystic Surge - Buff 5, Ranged buff 5, Damage 5

Warp Wood - Damage 1
Disrupt - Damage 1
Fire Bolt - Damage 4
Fireball - Damage 4
Lightning Bolt - Damage 6
Warp Lightning - Damage 8
Doom Bolt - Damage 7
Magic Vortex - Damage 7
Flame Strike - Damage 12
Chain Lightning - Damage 13
Apocalypse - Damage 15

Shatter - Curse 2
Warp Creature - Curse 2
Disintegrate - Curse 8

Fire Elemental - Summon 2

Blazing March - Initialbuff 6
Warp Reality - Initialbuff 9

Total : 5 Buff, 5 Ranged buff,  15 Damage, 8 Curse, 2 Summon, 15 Initialbuff = 50

Life

True Sight - Buff 1
Bless - Buff 2
Holy Weapon - Buff 3, Ranged buff 3
Heroism - Buff 3
Discipline - Buff 3
Lionheart - Buff 8, Summon 3
Invulnerability - Buff 10

Healing - Summon 2
Raise Dead - Summon 4
Exaltation - Summon 5
Mass Healing - Summon 5
Call to Arms - Summon 8

Star Fires - Damage 1

Exorcise - Curse 2
Holy Word - Curse 5

Prayer - Initialbuff 7
Supreme Light - Initialbuff 9
High Prayer - Initialbuff 12 but only +5 if Prayer already known

total : Buff 10, Ranged Buff 3, Summon 8, Curse 5, Damage 1, Initialbuff 21 = 48

Death

Wraith Form - Buff 1
Cloak of Fear - Buff 2

Zombies - Summon 3
Demon - Summon 5
Animate Dead - Summon 10

Life Drain - Damage 2
Syphon Life - Damage 4
Reaper Slash - Damage 5
Wave of Despair - Damage 8

Weakness - Curse 1
Black Sleep - Curse 3
Possession - Curse 6
Annihilate - Curse 10
Massacre - Curse 12

Darkness - Initialbuff 2
Mana Leak - Initialbuff 2
Mislead - Initialbuff 2
Black Prayer - Initialbuff 5
Terror - Initialbuff 5
Gate of Hades - Initialbuff 4

Total - Buff 2, Summon 10, Damage 8, Curse 12, Initialbuff 20 = 52
Reply

One question.

When the AI is the defender and it knows it will lose the battle, should it

1. cast no combat spells and save on MP
2. cast combat spells anyway, hoping to do enough damage to the other army to be able to counter attack next turn.

1 contributes to our goal of AI wars getting a clear winner via two means :
-the defender can save MP to spend on their offensive battles which they will win (but require MP to initiate unless they can win without casting).
-the attacker suffers less damage so they are more likely to be able to hold their conquered new city and/or keep fighting and destroying more stacks.

It also helps the AI avoid spending MP on fights where the attacker wouldn't suffer damage either way - remember the attacker will never launch an attack if they expect to take over 75% damage so the attacking stay actually losing good units is pretty much impossible. At best we can hope damaging the units and counterattacking next turn. However if we don't have another own army nearby that's good enough to do that, then the attacker's army will simply recover over time and we wanted our MP anyway.

So these are three very strong arguments for "1".

On the other hand, "2" is the more realistic behavior from a human player and generally the good strategy when on the losing side of a battle in one's own territory.

About "knows it will lose the battle", this is not a guesstimate but proper information that's guaranteed to be true. However, it doesn't know the details (how much damage can be done to the enemy with or without spellcasting) - I'm basically using the shortcut that if the attacker was an AI, we can be 100% sure we are losing because the AI never attacks otherwise and did a proper simulation of the battle to know the result.

Maybe saving the expected damage ratio after that simulation on the attacking army and reading that could help in the decision but that still doesn't guarantee we can counterattack and take advantage of that damage instead of it simply getting healed over time. But is it even worth the effort when our primary goal is to support the AI on the offense by the game mechanics?
Reply

Quote:When the AI is the defender and it knows it will lose the battle, should it

1. cast no combat spells and save on MP
2. cast combat spells anyway, hoping to do enough damage to the other army to be able to counter attack next turn.


This decision seems a bit difficult to me -- it's seems unpredictable how consistently doing a few points of damage in losing battles, over thousands of battles, will affect the course of the game. Also the mana expenditure will have an effect.

But for some wizards, it just doesn't matter if they spend mana. Some of them have a massive income and bank thousands of mana. Can this decision just be predicated on a formula incorporating available mana, the year, and the distance multiplier?

if current mana > base amount * distance multiplier + (year * modifier) then (cast or don't)

... something like that. IMO it's desirable to give wizards who have impossibly large amounts of mana another way to drain some off, in any case. When an AI wizard has 10k+ mana at the start of a war it's just strategically impossible to make their mana economy matter, which isn't great.
Reply

A mana saving mechanic based on amount available already exist.

However this isn't about that, this is about not spending mana on battles where spending it is not useful. Unlike normal combat, here the damage dealt usually doesn't result in dead units for the other side.

for example, the attacker doesn't spend mana when attacking units on the field (no city, node, or lair) and the number of enemy units is below 6. It's not worth spending mana on each small stack the enemy has, those can usually be killed without spending it.
This is something like that but for the defender side.

Also 10k+ mana does matter. The AI is keeping a certain amount of mana in reserve for unexpected spending (basically a war with a new player) which can easily use up the entire amount in 2-3 turns in the late game. The reserve doesn't come out of nowhere, each MP produced to refill it means 1 less RP or SP produced. So if the AI spent 5000 mana but still have the same amount that means they skipped raising their skill by 20 or skipped researching an entire rare spell.
There is only one exception to this, wizards with Alchemy who do have a lot of excess mana because they keep most of their mana in form of mana crystals. This allows them to do better on research and casting skill because they don't need to produce MP, but of course this means they won't spend as much on units and buildings as other wizards.
Reply

Quote:However this isn't about that, this is about not spending mana on battles where spending it is not useful. Unlike normal combat, here the damage dealt usually doesn't result in dead units for the other side.

Yes, but you're presuming it's not useful. If you know it's not useful; that it has absolutely no effect on the game; then why ask? Just turn off spellcasting. But as you phrased it, the AI may do some additional damage to other AIs, which seems like it may have unpredictable effects to me. And damage out in the world map is not that trivial, it can take a really long time to heal from, particularly with early game units.

So what I'm suggesting is an additional mana saving mechanic that has a higher bar than the existing one.

Quote:Also 10k+ mana does matter. The AI is keeping a certain amount of mana in reserve for unexpected spending (basically a war with a new player) which can easily use up the entire amount in 2-3 turns in the late game.

I'm not talking about late game. I'm talking about early-mid game when most wizards have a few hundred MP then there's some outlier with thousands. It's entirely different to play against that wizard in early vs late game. Which is why I suggested a scaling by year for the threshold on when wizards will spend their mana on losing fights.
Reply

Problem is the difficulty of drawing a line between the cases. I now have code for determining if an AI is weak and should be eliminated so at least that's available information.


Considering what we want to happen, the following is pretty much what we need - useless wizards should lose faster, mediocre wizards we don't really care either way but probably they should save mana to hope becoming relevant through research, while all other cases should focus on winning their wars to the best of their ability :


IF
(us=weak wizard) and (enemy=strong AI) and not (extra damage by spells is relevant)
OR
((us=strong wizard) or (enemy=human player)) and (extra damage by spells is relevant)
THEN spend mana.

That's pretty much working code right there except "extra damage by spells is relevant" is unknown and impossible to know. (in the first place we don't know if our spellcasting manages to raise the damage ratio of the enemy army above zero, and if it does, do we reach high enough that the dealt damage actually has relevance afterward.)

btw the last two days we had the "don't spend mana" version. It didn't seem to make weak wizards lose faster. I don't know if it had any effective, good or bad, on strong wizards.

Oh, wait, maybe we can find a solution by thinking outside the box, or in this case, the battle.

When weaker AIs attack stronger AIs, it's reasonable to assume the stronger AI has a stronger army available most of the time, and can crush the attacker in response, regardless of whether they did any damage in the combat they lost. Basically, the stronger AI has higher tier spells, more skill and probably equal or higher tier troops. Which means stronger AIs don't need to spend mana, they can counterattack even if the enemy wasn't hurt. Weaker wizards spending mana to lose faster might be desirable but if we manage to find a way to help them get eliminated (and we need to because combat spellcasting didn't do that) then not spending it is better - in the unlikely case they stay in the game despite all our efforts then saving mana to research better spells isn't bad. So in either case, don't spend mana.

The only exception is the intercontinental doomstack which might be too much to take on even for the strong wizard but it's questionable whether the weak wizard can even build one without the units getting sniped on their way and even if they do it's probably too slow and the units are probably not good enough to matter.

So I think our answer is to not spend mana on losing battles. (but either way we still need to work hard on making sure the weak wizards get themselves defeated somehow.)

PS : A bit of an explanation about that "raise above zero". Spellcasting can deal damage, armies can deal damage, but spellcasting can also add hit points. If the enemy army adds more hit points than they take damage then the damage ratio will be zero - basically they cancelled out the damage by healing, defensive or summoning spells.
Reply



Forum Jump: