MantisBT - VCMI
View Issue Details
0001112VCMIAI - Battlespublic2012-09-30 06:442012-09-30 16:16
Warmonger 
Tow 
normalcrashalways
closedduplicate 
0.89d 
 
0001112: BattleAI crash when AI can cast 0 spells
Best error message ever.
Reproductible with attached save - when blue attacks red castle.
No tags attached.
duplicate of 0001114closed Tow Crash on AI turn when Green hero attacks Purple town 
png Casting spells sounds like fun.png (6,964) 2012-09-30 06:44
https://bugs.vcmi.eu/file_download.php?file_id=1111&type=bug
png

rar Crash1112.rar (458,243) 2012-09-30 06:53
https://bugs.vcmi.eu/file_download.php?file_id=1112&type=bug
Issue History
2012-09-30 06:44WarmongerNew Issue
2012-09-30 06:44WarmongerStatusnew => assigned
2012-09-30 06:44WarmongerAssigned To => Tow
2012-09-30 06:44WarmongerFile Added: Casting spells sounds like fun.png
2012-09-30 06:53WarmongerReproducibilityhave not tried => always
2012-09-30 06:53WarmongerSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=1954#r1954
2012-09-30 06:53WarmongerFile Added: Crash1112.rar
2012-09-30 06:56WarmongerSummaryBattleAI crash when AI knows 0 spells => BattleAI crash when AI cna cast 0 spells
2012-09-30 06:56WarmongerDescription Updatedbug_revision_view_page.php?rev_id=1956#r1956
2012-09-30 06:56WarmongerSummaryBattleAI crash when AI cna cast 0 spells => BattleAI crash when AI can cast 0 spells
2012-09-30 11:34TowNote Added: 0003136
2012-09-30 11:34TowStatusassigned => closed
2012-09-30 11:34TowResolutionopen => duplicate
2012-09-30 11:34TowRelationship addedduplicate of 0001114
2012-09-30 13:40ZamolxisNote Added: 0003141
2012-09-30 13:41ZamolxisNote Edited: 0003141bug_revision_view_page.php?bugnote_id=3141#r1967
2012-09-30 14:09TowNote Added: 0003144
2012-09-30 14:56ZamolxisNote Added: 0003145
2012-09-30 15:35TowNote Added: 0003146
2012-09-30 16:16ZamolxisNote Added: 0003147

Notes
(0003136)
Tow   
2012-09-30 11:34   
Duplicate to 0001114 — it is related to handling shooting towers, not an AI issue.
Fixed in r2960.
(0003141)
Zamolxis   
2012-09-30 13:40   
(edited on: 2012-09-30 13:41)
Strange that it's duplicate, because the text on my Console was saying something else (really about the towers).

But nevertheless, it was fun to see such Console message... :-) Who coded it like this, and when is it supposed to appear? Perhaps when AI tries to make a non-casting creature/object to cast a spell?

(0003144)
Tow   
2012-09-30 14:09   
> Strange that it's duplicate, because the text on my Console was saying something else (really about the towers).

It is because you used StupidAI, and here is the BattleAI — their output is different.
The bug happens, when AI asks about tile accessibility for current stack, if the current stack is towers.

> Who coded it like this, and when is it supposed to appear? Perhaps when AI tries to make a non-casting creature/object to cast a spell?

It was me.

Algorithm is:
1) Get list of spells the hero can cast (first log), erase the ones we don't know how to work (second log).
2) Create list of all possible {spell, target} pairs. (third log)
3) If the list is empty (no possible casts), abort casting. (no log unfortunately)
4) Select the best cast and attempt it.

AI didn't try any casting here. (If it would, it would give an explicit message.) After collecting a list of possible casts, it checked for it size. If it is zero it aborts casting and starts thinking about stack. Which was the turret.
(0003145)
Zamolxis   
2012-09-30 14:56   
Thanks for all the details. I didn't realize the Stupid/BattleAI could be the reason the messages are different.


One question though: did the defending castle have a hero with Ballistics? Otherwise I'm not sure the approach is correct. Heroes cannot cast before the turrets unless they have Ballistics. Unless it's a logic restricted to AI vs AI battles only which speeds up the calculation of casualties.
(0003146)
Tow   
2012-09-30 15:35   
> One question though: did the defending castle have a hero with Ballistics?

It's the Artillery skill that gives control over turrets. Yes, there was a hero with garrison, all seems legit. :)
AI uses the same engine procedures to check if casting spell is possible at given moment, so there should not be any bugs. (though... we never know.)


> Unless it's a logic restricted to AI vs AI battles only which speeds up the calculation of casualties.

We don't have such technique, all battles are played using the same rules.
(0003147)
Zamolxis   
2012-09-30 16:16   
Thanks. And good to know there aren't different rules for AI.