Hmm...I had a recent run-in with my own Arena deck where its field was almost filled with Skeletons (unupped) as well as 2 Otyugh. I had about 8 Giant Frogs on the field, but at some point the AI turned away from Devouring my Frogs and instead began to try and eliminate its own Skeletons.
Is there something in the code that causes the AI to switch its targeting priority once its field becomes filled to a certain point?
The answer is found here (
http://elementscommunity.org/wiki/articles/coding-of-the-game-ai/#Autotarget).
If skill is “devour”:
estimate = -1
targeting = "smaller"
Now scrolling down a bit:
If skill is targeting “smaller”
This targets a creature to be devoured.
Loop through all the AI’s creatures with less def than the devouring creature.
If creature is poisoned or (current ATK + current def < 3 and it has no active skill):
score[AI creature] = -estimate / 10
If AI has more than 20 creatures:
score[AI creature] = -estimate / (current ATK)
Loop through all the player’s creatures with less def than the devouring creature.
If creature has an active skill:
skillscore = 3
Now calculate score:
score[player creature] = (skillscore + 1 + current ATK) / -estimate / 10
This piece of code is used to calculate Giant Frog's score:
score[player creature] = (skillscore + 1 + current ATK) / -estimate / 10
So:
score[Giant Frog] = (0 + 1 + 5) / 1 / 10 = 6/10 = 3/5 {Because Giant Frog has no skill, skillscore is 0}
Normally, this piece of code is used to calculate Skeleton's score:
If creature is poisoned or (current ATK + current def < 3 and it has no active skill):
score[AI creature] = -estimate / 10
So,
score[Skeleton] = 1/10, as opposed to Giant Frog's 3/5. Therefore, it devours Giant Frog over Skeleton.
However, when the AI has more than 20 creatures, Skeleton's score is calculated like this:
score[AI creature] = -estimate / (current ATK)
So,
score[Skeleton] = 1 / 1 = 1.
Skeleton's score is now 1, as opposed to Giant Frog's 3/5, hence it devours Skeleton.
tl;dr: When AI has more than 20 creatures, turns masochistic.