Closed kozalosev closed 3 weeks ago
The kernel does have an estimate on the amount of entropy available (readable from /proc/sys/kernel/random/entropy_avail)
$ cat /proc/sys/kernel/random/entropy_avail
256
Everything's fine with the entropy pool.
I discussed this topic with more experienced in gambling colleagues yesterday. Mathematically and in implementation, everything must be fine. We don't need another Rng
engine, nor any metrics.
https://github.com/kozalosev/DickGrowerBot/pull/35
This is not the log I said above, but at least now we'll have some statistics.
Just to chime in, we recently did some PvP battles in a group chat and nearly everyone lost in multiple bets against a friend:
Some of the top 10 did not participate in battles or only lost a bit, but the randomness seems odd to me. I think maybe the size of both sides and the value they are betting on should be factored into the odds to balance things out.
Recently, I have received several messages concerning about possible unfairness of the PvP battles in the bot. I decided to describe this arguable and discussable issue once and refer them all here.
Some participants of the game allegedly have a win rate of about 80-90%. I understand this may look suspicious, but this is not sufficient to conclude the randomness is not random. To make some conclusions, we must take into consideration a total number of battles conducted by the user. In probability theory, results are uniformly distributed only when the number of attempts tends to infinity. In real life, we have to deal with hundreds or thousands of attempts. True randomness on a small sample can seem very non-random for humans. It's normal. It doesn't mean something is broken. Even more, to better understand what's happening, it's desirable to collect statistics of battles for all the users. Unfortunately, I haven't implemented such functionality yet, sorry.
Implementation details
The code to choose a winner is very simple:
OsRng uses the
getrandom()
system call to get a truly random value from physical sensors on a physical machine, and applies a Bernoulli distribution over it to get a boolean value:However, I think there may be a problem: the bot is running on a virtual machine which has a shared pool of randomness/chaos. Theoretically, it means that other applications on the same machine can use that pool, and it can be constantly empty. But this hypothesis requires further investigation and addition of corresponding metrics.
Tasks
Taking into account the said above, let's formulate a list of tasks to do to prove or disprove the fairness of the randomness:
Rng
engines at runtime.Other ideas?
If someone else has other thoughts, I would be glad to listen to them here.