openomf icon indicating copy to clipboard operation
openomf copied to clipboard

Demo has a super high probability of matching the same pilot against themselves

Open Snafulator opened this issue 3 years ago • 3 comments

As the title says. If you watch the demo enough you will notice that >50% of the time the pilot will be matched up against themselves.

We might need to look into an alternate random number generator for seeding the pilot_id/har_id.

Not a big deal this one obviously but having an alternate rand_int method somewhere would be a major improvement and i could re-use it in the AI logic too.

Snafulator avatar Jul 07 '21 07:07 Snafulator

Having a better random generator is probably a good idea. Only point is that the generator must be seedable and produce consistent results on different machines when using matching seeds (for network support).

katajakasa avatar Aug 15 '21 17:08 katajakasa

The problem is probably because on insufficiently random low-order bits in the generator and a bad algorithm for range reduction.

I suggest PCG as a generator. It's small, fast and has good randomness.

For range reduction check out https://www.pcg-random.org/posts/bounded-rands.html. TL;DR: there's a bunch of ways of doing it, most of them wrong in some way. Pick one of the ready-made unbiased ones to avoid strange issues like this.

turol avatar Aug 16 '21 08:08 turol

Huh, didn't know about PCG, seems good to me.

katajakasa avatar Aug 16 '21 14:08 katajakasa