Piranha,
Thanks for that link. I'll do some reading up on it.
piranha wrote:I can't really comment on the randomness but I don't think the php function is broken. I run the function and the number it returns is the number you see in the scroll to the right.
Scroll to the right? Not sure what you mean by that. I don't see anything on the right.
piranha wrote:I'm absolutely no guru with this type of stuff, but my own experience is that with 1000 tests there is quite a lot of room for randomness left. I did some tests of 1000 runs and I got numbers that are +-15 very often and +-20 now and then.
Some of the randomness depends on the seed value. Are you for example re-seeding the generator once a day? Once per game load (ie each time someone starts their turn do they get a custom random seed), once per battle etc.
I added the following to my code
- Code: Select all
int main(void)
{
int outlier = 0;
int totals[20];
srand(time(NULL));
for (int i=0; i<20; i++)
{
totals[i] = 0;
}
for (int i=0; i<1000; i++)
{
totals[(rand()%20)]++;
}
for (int i=0; i<20; i++)
{
printf("%d %d's ", totals[i], i+1);
if (totals[i] < 35 || totals[i] > 65) outlier++;
}
printf("\n");
printf("The number of outliers is %d\n", outlier);
}
And I get:
40 1's 44 2's 60 3's 52 4's 62 5's 53 6's 60 7's 57 8's 43 9's 45 10's 43 11's 45 12's 52 13's 48 14's 55 15's 49 16's 38 17's 53 18's 50 19's 51 20's
The number of outliers is 0
49 1's 42 2's 54 3's 49 4's 43 5's 52 6's 56 7's 48 8's 47 9's 51 10's 62 11's 52 12's 47 13's 55 14's 43 15's 51 16's 47 17's 57 18's 47 19's 48 20's
The number of outliers is 0
55 1's 46 2's 55 3's 68 4's 45 5's 47 6's 49 7's 59 8's 46 9's 48 10's 51 11's 39 12's 56 13's 44 14's 56 15's 45 16's 51 17's 51 18's 48 19's 41 20's
The number of outliers is 1
59 1's 49 2's 53 3's 56 4's 59 5's 44 6's 43 7's 44 8's 40 9's 36 10's 58 11's 44 12's 53 13's 54 14's 56 15's 46 16's 45 17's 56 18's 46 19's 59 20's
The number of outliers is 0
59 1's 50 2's 39 3's 43 4's 48 5's 48 6's 54 7's 56 8's 48 9's 51 10's 52 11's 49 12's 43 13's 54 14's 50 15's 48 16's 53 17's 60 18's 51 19's 44 20's
The number of outliers is 0
So I got one outlier (15+ off the average value of 50) in 5 runs of the program. That's about what I average if I run my program once every 3-4 seconds (to allow the random seed time to change based on the clock for the next running).
Not sure it proves anything one way or another about the random function itself but if you are getting a lot more outliers then it would seem to indicate that maybe you need to reseed more or less often.
piranha wrote:My own experience is that warlords (1 on amiga and 2 DLX on pc) have too much randomness in the battles. I know we stopped playing warlords 1 because we were unhappy with the battle randomness. We did a bit of test with castles with 28-32 units in that were attacked by a good hero stack and the result could go any way. One side could crush the other or the reverse. We thought it was too much random to be fun.
That's interesting. Mostly because Warlords 1 used a maximum dice roll of 10 instead of 20. I would have expected that to mean much smoother results and far fewer outliers.
piranha wrote:In my opinion there is no goal to make the battle calculation exactly like warlords just because thats they way the original handled it.
I want the outcome from battles to be more predictable than it is now.
I think everyone wants this.
But predictable to me means that if 8 identical units fight (8 light infantry vs 8 light infantry) then the outcome shouldn't be one side wins with 4-8 units left. It means one side should win with 3 or fewer units left. That's because 75% of all possible outcomes have one side or the other winning with 3 or fewer units left.
piranha wrote:I think we are going to try with a system where units have different HP, perhaps 1 turn units 3HP, 2turn 4HP, 3turn 5HP and so on. All your units will heal when you start your turn but not between battles.
This doesn't do anything to make battles more predictable. All this does is make 2, 3, 4 turn units MUCH better. If that's what you are trying to achieve with predictable then it will work. But if you want to prevent wild swings in outcomes this won't help in the least.
Again, here is some code I wrote modified to show 8 light infantry fighting 8 light infantry. This time it counts only the number of units remaining for the winner.
- Code: Select all
nt main(void)
{
int hitsStack1 = 16;
int hitsStack2 = 16;
int strStack1 = 2;
int strStack2 = 2;
int winsStack1 = 0;
int winsStack2 = 0;
int unitsLeftStack1 = 0;
int unitsLeftStack2 = 0;
int avgUnitsLeft[9];
srand(time(NULL));
for (int i=0; i<9; i++)
{
avgUnitsLeft[i] = 0;
}
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 (hitsStack1 == 0)
{
winsStack2++;
unitsLeftStack2 = unitsLeftStack2 + (hitsStack2+1)/2;
avgUnitsLeft[(hitsStack2+1)/2]++;
}
if (hitsStack2 == 0)
{
winsStack1++;
unitsLeftStack1 = unitsLeftStack1 + (hitsStack1+1)/2;
avgUnitsLeft[(hitsStack1+1)/2]++;
}
hitsStack1 = 16;
hitsStack2 = 16;
}
for (int i=1; i<9; i++)
{
printf("%d %d's ", avgUnitsLeft[i], i);
}
printf("\n");
}
Running the code I get
2918 1's 2661 2's 2179 3's 1369 4's 622 5's 222 6's 27 7's 2 8's
So you can see that winning with 3 or less units left is 2918+2661+2179=7758 or 77.58% of the time. 4 or less units left is 7758+1369 = 91.27%.
Now when I changed the hit points from 2 to 4 (16 to 32) and ran again I got
2844 1's 2699 2's 2127 3's 1395 4's 676 5's 222 6's 37 7's 0 8's
Virtually the same results. There is still going to be a 10% chance one side wins with 5+ units left and a 25% chance one side wins with 4+ units left.
So what you have to decide is whether or not you want to fix THIS problem. This is the problem to me that is the biggest issue. The fact that you can get those outlier cases where someone gets WAY too lucky with the result.
The answer to me is you have to ignore the outliers and completely re-do the battle. The only question is whether you set the outlier case at 90% or 75% or 80%.
I honestly don't think the other problem of needing more hits for 2,3,4 and 5 turn units is that big of an issue if you just adjust slightly some of the strengths/bonus's on a few units like Light Cavalry, Elves, Elephants etc. In my mind making 2,3,4 and 5 turns units better is completely separate issue from battle balance and will require a LOT more work in terms of redoing unit strengths, costs, turns etc (Lets just say after 10 years DLR is STILL trying to get it perfectly right so that 50% of the 100+ units in DLR aren't completely useless).
Please, please, please on the system where you get 3 hits for 1 turn, 4 hits for 2 turns and 5 hits for 3 turns cap the hits at 5. An Archon/Devil/Dragon with 7 hits is just going to be WAY too hard to kill. I ran some numbers and an 8 strength Devil (7 plus his stack bonus) with 7 hits is 90% likely to kill 8 light infantry (2) strength and 50% likely to kill 8 heavy infantry (3) strength. I can definitely say that under this combat system the most valuable unit in the game is going to be Ghosts for their critical chance skill as it will be the only way to slow down big stacks.
KGB