BuzzerBeater Forums

Bugs, bugs, bugs > Put at least some random in GE

Put at least some random in GE

Set priority
Show messages by
This Post:
11
263046.13 in reply to 263046.12
Date: 10/7/2014 8:12:47 AM
Overall Posts Rated:
32293229
Server time at the time the game is calculated? Depending on how much precision you're using, given that the games start calculating at the same time every game night for a given nation's games, that could lead to the same duplicate seeds. If it's c++ I'm not sure of the equivalent, but I'd probably use something like DateTime.Now.Ticks in C# to get a unique seed.
@GM-Hrudey: "The value returned generally represents the number of seconds since 00:00 hours, Jan 1, 1970 UTC (i.e., the current unix timestamp).", which is similar something like this 414086872.


I think we'd had this same discussion previously when this came up and I just plain forgot it.

The only thing new I can think of, and this is even pretty unlikely, is that while the random seed is being assigned to some instance of an RNG, either when the calculations are using it they're either implicitly creating new random number from a new RNG, or possibly threading timing issues causing the RNG to be used before the seed is assigned. I don't think either of these is likely, especially the latter since it doesn't even seem to be a very likely design for this.

If it makes you feel any better, I understand how annoying this can be. I literally had a block of code where if I didn't do the following:

if (sli != null)
{
if (sli != null)
{
linenumber = sli.AltLineNumber;
}
}

I would get a null reference error because it would show as not null at first, but then null when I tried to access the property. I never did determine precisely what caused it other than finding that when I cleaned up some mistakes I mde in multithreading, it worked again. But it only affected that specific area of the code - inside other processes using the exact same code, it never failed.

But that's the life we choose. Just think in another ten years, with Moore's law, what the computers will do to us if they don't like our code then!


From: RSX

This Post:
00
263046.14 in reply to 263046.12
Date: 10/7/2014 9:51:03 AM
Overall Posts Rated:
181181
So how comes these two games are identical? Using srand with unix timestamp should give you different random values for these two games. I see no problem with C++ here (not to mention stdlib is a C library).

Last edited by RSX at 10/7/2014 9:51:20 AM

From: BB-Marin

To: RSX
This Post:
00
263046.15 in reply to 263046.14
Date: 10/8/2014 6:44:58 AM
TrenseRI
III.2
Overall Posts Rated:
36003600
Second Team:
ChiLeaders
I ask myself the same question: how? But it is. And Charles had the same problem, couldn't fix it. And he's a top notch programmer (understatement).

From: aamcguy

To: RSX
This Post:
00
263046.16 in reply to 263046.14
Date: 10/9/2014 12:29:42 PM
Overall Posts Rated:
1919
The problem with random number generators is that they aren't actually 100% random. Depending on how the stream is manipulated, even different seeds can create identical sequences for limited data sets.

Even with the limited chance of this happening, it could have all been avoided had at least one team played with a different attitude, had a different starting enthusiasm in game 1 so enthusiasm decay was different, set a different lineup, selected a different coach setting, played a different offense, played a different defense, or even guessed at their opponent's tactics.

Last edited by aamcguy at 10/9/2014 12:31:08 PM

From: RSX

This Post:
00
263046.17 in reply to 263046.16
Date: 10/9/2014 2:44:50 PM
Overall Posts Rated:
181181
If those two seeds were generating identical random numbers, then I'm pretty sure they would discover it quickly.

From: GM-hrudey

To: RSX
This Post:
00
263046.18 in reply to 263046.17
Date: 10/9/2014 3:01:40 PM
Overall Posts Rated:
32293229
If those two seeds were generating identical random numbers, then I'm pretty sure they would discover it quickly.


And this has happened on enough occasions that it wouldn't be likely to be the case anyhow. (Well, technically since it's random I suppose it's possible at a very low probability, but not as a practical consideration). I still wonder if it's a case of either the RNG instance being on the server/service level and not refreshing once created unless the server/service stops, or if it's a case of some call creating a new default random number generator rather than the one initialized with the time-based seed. I also am glad I am not the one who has to try to figure that out.

From: aamcguy

To: RSX
This Post:
11
263046.19 in reply to 263046.17
Date: 10/9/2014 3:12:40 PM
Overall Posts Rated:
1919
Without knowing how the generated numbers are being used, I can't comment more specifically. Different seeds would most definitely yield distinct streams of pseudo-random numbers.

However, the practical random number stream is influenced by how many possibilities they are testing for with each call to the random number and how many number of times the function is called. For example, if you are using a random number to check for a pass-fail--even if you weight the results due to player characteristics/strategy, etc--it still comes down to a test of even vs. odd numbers. So for each call, there would be between perhaps 30 to 70% of all random numbers that would allow the same result.

Now, the chances of this happening exactly the same way twice with different random number streams obviously decreases with each successive call (and even further if there are more complicated decisions happening), but it's not like an incredible lack of randomness gets noticed on a weekly basis.

People should be happy, given an assertion from admins that there are at least some random factors, that by and large if you build a strong team and make strong tactical choices you are going to get rewarded for it.