Are you, in fact, a pregnant lady who lives in the apartment next door to Superdeath's parents? - Commodore

Create an account  

 
AI Spell Ward

Currently, when casting Spell Ward, the AI does the following :

1. Find the next owned city not yet checked
2. If city has lower value than the already selected target, go to 1.
3. If the city is not warded against the Human Player's Primary realm, select as target city with that realm as the chosen type and go to 1.
4. If the city is not warded against the Human Player's Secondary realm, select as target city with that realm as the chosen type and go to 1.
5. If the city is already warded from both realms, there is a 96% chance to go to 1
6. Select the city as the the target and the realm is random

This is wrong on so many levels I don't know where to begin.

First, it will always look at the human player. The AI won't bother to protect itself from other AI, not even if they are at war! I believe protecting from the human player in all cases is fine, since they can, and usually will attack without a warning, so casting the wards afterwards is too late. However, the AI should, at least cast wards against players at war with him, or players that aren't at war but might - either low relation or lack of wizard's pact can be the condition here.

Second, it looks at "primary realm" and "secondary realm". If the player has books of 3 or more realms, those are pretty much ignored, furthermore, if they had only one (or zero) realm and found books, those will be ignored as well. (It's unlikely but entirely possible to find even 5-6 books of a realm in a game, possibly outweighting the starting realms)

Third, the random part. For starters there is a 40% chance to select a realm already warded against, resulting in the spell doing nothing. Then there is the problem of casting wards against realms possibly no one is playing...

And Fourth, it does not consider the wizard's own realms. While that was fine with the original effects, it definitely is not now, but I don't know how exactly the condition should be set up. Countering own combat spells is bad enough, but it might be helpful if the enemy uses their spells better, or simply has better spells to use. However the risk of casting the Ward on a city possibly being defended by units of that realm, which would then suffer a major penalty in combat - especially this being the most likely on the capital - sounds far too much. Checking the already existing creatures in the city should be doable, but they might get replaced by stronger creatures of another realm AFTER the ward was added to the city. So either the AI needs to simultaneously learn to kick out creatures of the wrong realm from their cities, or not cast wards of realms they have - at the very least not if their most expensive summoning spell (which is the unit that stays in the city) is of that realm. Again this poses the problem, what if the AI learns that summoning spell after casting the ward. The easiest would be to just say "no ward if books>=3" but then we'll never ever see a Sorcery Ward cast.

Fortunately there is plenty of space to code almost anything possible, the hard part is, how exactly should the AI judge which realm is safe to ward against without committing suicide? How paranoid should the AI be, which players should it consider as threats?
Reply

I believe the following should be an adequate solution :

When looking for a target :
1. Make a list of players who are threats. The human player is always a threat. Other AI are a threat if no Alliance or Wizard's Pact exists. Self is never a threat.
2. Count the sum of books those players have for each realm. For example 3 enemy players having 7 sorcery books each puts 21 in the sorcery total.
3. Subtract own books from the above totals.
3a. If Doom Mastery is in effect, set Chaos total to zero (or lower).
4. Find the next owned city not yet checked. If there are no more, done.
5. Count the number of fantastic creatures in that city for each realm.
6. Find the next ward type not considered. If there are no more, got to 4.
7. If that ward is already on the city, or there are 3 or more creatures of the realm in the city, or the total "sum" for that realm is non-positive, that's a bad ward, go to 6.
8. Calculate (City value+4*(sum for realm of the ward)). If it's lower than our selected target, go to 6.
9. Store found city and realm as the intended target, go to 6.

At end of turn :
Check all cities owned. If any contains 3 or more fantastic units of a realm, cancel the matching ward on the city.
Reply



Forum Jump: