MantisBT - VCMI
View Issue Details
0001081VCMIMechanics - Battlespublic2012-09-21 01:422014-05-30 17:41
GrayFace 
Ivan 
normalminoralways
closedfixed 
 
0.9 
0001081: Incorrect Death Stare algorythm
Here is the correct one from Heroes 3:
if (<target is alive>)
{
  int x = 0;
  for (int i = 0; i < gorgons_count; i++)
  {
    if (1 + rand()%100 <= 10) x++;
  }
  x = min(x, (gorgons_count + 9)/10);
  <kill x creatures>;
}
Note that no magic resistance is applied.
No tags attached.
related to 0001137closed Warmonger Mighty Gorgon's Death Stare vs Dwarf's Magic Resistance 
Issue History
2012-09-21 01:42GrayFaceNew Issue
2012-09-21 10:31IvanNote Added: 0003040
2012-09-21 10:31IvanStatusnew => feedback
2012-09-21 11:27IvanNote Edited: 0003040bug_revision_view_page.php?bugnote_id=3040#r1910
2012-09-21 14:10GrayFaceNote Added: 0003041
2012-09-21 14:10GrayFaceStatusfeedback => new
2012-09-26 09:04IvanAssigned To => Ivan
2012-09-26 09:04IvanStatusnew => assigned
2012-09-26 09:32WarmongerNote Added: 0003045
2012-09-26 09:52IvanNote Added: 0003046
2012-09-26 10:28GrayFaceNote Added: 0003047
2012-09-26 13:14IvanNote Added: 0003048
2012-09-26 13:14IvanStatusassigned => resolved
2012-09-26 13:14IvanFixed in Version => 0.9
2012-09-26 13:14IvanResolutionopen => fixed
2012-10-06 09:22ZamolxisIssue cloned: 0001137
2012-10-06 09:22ZamolxisRelationship addedrelated to 0001137
2014-05-30 17:41beegeeStatusresolved => closed

Notes
(0003040)
Ivan   
2012-09-21 10:31   
(edited on: 2012-09-21 11:27)
That's how current version works.
Only difference is implementation: instead of for loop random distribution is used

Used distribution: http://en.wikipedia.org/wiki/Poisson_distribution [^]

(0003041)
GrayFace   
2012-09-21 14:10   
Not at all.
1) It uses Poisson distribution instead of the correct one, Bernulli distribution. Bernulli would act like Poisson when there are many gorgons, but when there's 1 gorgon it would be able to kill more than 1 enemy if Poisson distribution is used.
2) It doesn't cap killed count at (gorgons_count + 9)/10.
(0003045)
Warmonger   
2012-09-26 09:32   
Oh, right about distribution. I forgot it already :P

Keep in mind that Death Stare can have different probability than 10%. I would change it to

int cap = 100/probability;
x = min(x, (gorgons_count + probability-1)/cap);
(0003046)
Ivan   
2012-09-26 09:52   
Right now probability comes from valOfBonuses so 10% are not hardcoded. But cap is missing. Will fix.
(0003047)
GrayFace   
2012-09-26 10:28   
Warmonger, perhaps you mean this: x = min(x, (gorgons_count*probability + 99)/100); I think that would be right.
BTW, WoG does much more calculations on each step of the loop. I've checked and 9999 gorgons still don't cause any delays. WoG also doesn't change the cap when using different probability, which is wrong.
(0003048)
Ivan   
2012-09-26 13:14   
fixed in rev 2924