The program Zajoman posted above was an earlier one showing a strength 6 vs strength 4 unit.
Here it is modified for the Spider vs Hero Stack battle
- Code: Select all
int main(void)
{
int hitsStack1 = 2;
int hitsStack2 = 16;
int strStack1 = 9;
int strStack2 = 4;
int winsStack1 = 0;
int winsStack2 = 0;
int unitsLeftStack1 = 0;
int unitsLeftStack2 = 0;
srand(time(NULL));
for (int i=0; i<10000; i++)
{
while (hitsStack1 > 0 && hitsStack2 > 0)
{
int rollStack1 = (rand()%20) + 1;
int rollStack2 = (rand()%20) + 1;
if (rollStack1 <= strStack1 && rollStack2 > strStack2) hitsStack2--;
if (rollStack2 <= strStack2 && rollStack1 > strStack1) hitsStack1--;
if (hitsStack2 == 6) strStack2 = 7; // Switch to Hv Calv
if (hitsStack2 == 2) strStack2 = 8; // Switch to Hero
}
if (hitsStack1 == 0)
{
winsStack2++;
unitsLeftStack2 = unitsLeftStack2 + (hitsStack2+1)/2;
}
if (hitsStack2 == 0)
{
winsStack1++;
unitsLeftStack1 = unitsLeftStack1 + (hitsStack1+1)/2;
}
hitsStack1 = 2;
hitsStack2 = 16;
strStack1 = 9;
strStack2 = 4;
}
printf ("Spider Stack won %d battles with an average of %f units left\n", winsStack1, unitsLeftStack1/10000.0);
printf ("Hero Stack Stack won %d battles with an average of %f units left\n", winsStack2, unitsLeftStack2/10000.0);
printf ("The Spider Stack winning percentage is %f\n", (float)winsStack1/10000.0);
}
Note: This program could be easily modified to actually have a GUI and let players select the units on both sides, work out the bonus's and then do the battle.
If you want to simulate using the new combat system simply change these lines:
int hitsStack1 = 2;
int hitsStack2 = 16;
if (hitsStack2 == 6) strStack2 = 7; // Switch to Hv Calv
if (hitsStack2 == 2) strStack2 = 8; // Switch to Hero
hitsStack1 = 2;
hitsStack2 = 16;
to
int hitsStack1 = 4;
int hitsStack2 = 26;
if (hitsStack2 == 11) strStack2 = 7; // Switch to Hv Calv
if (hitsStack2 == 3) strStack2 = 8; // Switch to Hero
hitsStack1 = 4;
hitsStack2 = 26;
Note: Working out the avg units left is more complex in the 2nd case due to the uneven number of hits per unit so I am not showing that here.
KGB