Page 1 of 1

Implementation of the function bga_rand

Posted: 16 May 2024, 13:15
by bidulpik
Howdy,
can we have the implementation of the function
bga_rand please
it is to proove customers that our code is correct according to the randomizer.
I've seen this interesting article on the forum :
viewtopic.php?t=18290
And this conribution in the group :
https://boardgamearena.com/group?id=1224884
(title = ❤ There is no problem with dice randomizer ❤ )

I'll look for social science article about the feeling of wrong randomizer to explain to customer that dont beleive me for the game I develop for BGA, the backgammon.

Best regards

Re: Implementation of the function bga_rand

Posted: 16 May 2024, 13:47
by ufm
I'm currently maintaining Yahtzee. I stopped bothering as they can't prove anything they say. Imo they just need something or someone to blame.

Re: Implementation of the function bga_rand

Posted: 16 May 2024, 13:48
by bennygui
Search bga_rand on this page: https://en.doc.boardgamearena.com/Main_ ... e.game.php

It says: "As of now, bga_rand is based on the PHP function "random_int", which ensures a cryptographic level of randomness."

So now you have to check how random_int is implemented in PHP!

Re: Implementation of the function bga_rand

Posted: 16 May 2024, 13:56
by RicardoRix
it's like a rabbit hole inside a rabbit hole.
I wonder if Alice will find the right potion.

Re: Implementation of the function bga_rand

Posted: 16 May 2024, 14:43
by CitadelUK
bennygui wrote: 16 May 2024, 13:48 Search bga_rand on this page: https://en.doc.boardgamearena.com/Main_ ... e.game.php

It says: "As of now, bga_rand is based on the PHP function "random_int", which ensures a cryptographic level of randomness."

So now you have to check how random_int is implemented in PHP!
Feels like this comes up so often that it would help to have a standard answer for this.

Die rolling and card shuffling in BoardGameArena use cryptographically secure randomisers that are more random than physically rolling dice or shuffling cards.

https://en.doc.boardgamearena.com/Main_ ... d_bga_rand "As of now, bga_rand is based on the PHP function "random_int", which ensures a cryptographic level of randomness."
https://www.php.net/manual/en/function.random-int.php "A cryptographically secure, uniformly selected integer from the closed interval [min, max]."
https://man7.org/linux/man-pages/man2/getrandom.2.html "The random source is limited based on the entropy that can be obtained from environmental noise."
https://en.wikipedia.org/wiki/Entropy_(computing) "The Linux kernel generates entropy from keyboard timings, mouse movements, and integrated drive electronics (IDE) timings and makes the random character data available to other operating system processes through the special files /dev/random and /dev/urandom."

Re: Implementation of the function bga_rand

Posted: 16 May 2024, 14:50
by GTSchemer
It's very easy to get a developer account, and many users on this forum are developers, myself included.

It is trivial to run bga_rand() many times, take the output, and put it into a curve fitter. I believe this has been done before (maybe multiple times), and when done, gives a very strong confirmation that the number distribution is as expected over a large sample.

Obviously taking a very small sample will not always be evenly distributed, just like you can flip a coin and see heads 4 times in a row.


Anyone unwilling to do (or consider) this basic mathematical test is likely not arguing in good faith.

Re: Implementation of the function bga_rand

Posted: 17 May 2024, 07:36
by JimBut
I don't think showing the code would help convince someone that there is a sitewide conspiracy to tailor the randomiser to each specific game.

People tend to be bad at dealing with randomness, even the open source backgammon game GNUBG gets accused of cheating or not being random and you can examine the code base for that.

As an aside I'm loving the new Backgammon implementation bidulpik!

Re: Implementation of the function bga_rand

Posted: 17 May 2024, 11:05
by Lunalol
Then, one day, a student who had been left to sweep up after a particularly unsuccessful party found himself reasoning in this way: "If such a machine is a virtual impossibility, it must have finite improbability. So all I have to do, in order to make one, is to work out how exactly improbable it is, feed that figure into the finite improbability generator, give it a fresh cup of really hot tea... and turn it on!" He did this and managed to create the long sought after golden Infinite Improbability generator out of thin air. Unfortunately, shortly after he was awarded the Galactic Institute's Prize for Extreme Cleverness, he was lynched by a rampaging mob of respectable physicists on the ground that he has became the one thing they couldn't stand most of all: "a smart arse".
From https://hitchhikers.fandom.com/wiki/Inf ... lity_Drive

Conclusion, in the BGA premises, there is a fresh cup of really hot tea whose Brownian motion is used by the entropy generator of the Linux kernel.