Teapot wrote: ↑17 July 2020, 14:22
Ze Monstah wrote: ↑08 March 2020, 23:11
Backgammon BGA adaptation has been developed by a member of the BGA community: You can send him a message if you want::
https://boardgamearena.com/player?id=2892085
Here is the PHP code that he wrote to roll the dice:
Code: Select all
// Roll dices
$dice1_value = bga_rand(1, 6);
$dice2_value = bga_rand(1, 6);
bga_rand() function is defined like this:
Code: Select all
function bga_rand( $min=null, $max=null )
{
if( $min === null && $max === null )
return random_int( 0, getrandmax() ); // For compatibility
else
return random_int( $min, $max );
}
What is the purpose of getrandmax and default null inputs. Seems to me if the function is ever called with improper values it's a serious bug
OK, the programming aspect of it.
BGA first developed a random number generator* function called bga_rand(a,b). Normal application is to return an integer value between the values of the parameters passed to it (a and b), inclusive. However, it could have been called without parameters (bga_rand()), returning a value between 0 and the maximum integer the system would handle.
While this method worked fine for casual games and computing capability of personal computers when the site was originally created, better options became available. Namely the PHP function random_int(a,b). So, bga_rand(a,b) was rewritten to simply call random_int(a,b). This would cause all programs to update to the better option without requiring looking through all the games and finding every instance of a call to bga_rand(a,b) and replacing it with random_int(a,b).
But, since bga_rand() could be called without parameters, the ability to recreate that had to be included. Which is why there's the comment "for compatibility" in the call if no (or null) parameters were passed to the function. Yes, it could be a valid call of bga_rand(null, null).
As far as calling it with improper values, that is still as much of an issue as it was**. Note that if bga_rand(a) is called (only one parameter), it will make a call to random_int(a, null), which will throw a TypeError exception. **But, it never really was much of an issue. The exception being thrown would cause the program to fail, and would never make it to the production server. Any code written to catch that error would be done by a programmer that wouldn't send improper arguments in the first place.
-------
*For purists, yes, it is actually a pseudo-random number generator, as are all computer generated random numbers.
Teapot wrote: ↑17 July 2020, 14:22
and could well be a factor in the backgammon artifact we've all noted.
We've
all noted? I have yet to see an analysis in the backgammon forums that proves an issue. Please provide that analysis rather than simply making the assumption we have all seen an artifact.
Teapot wrote: ↑17 July 2020, 14:22
I don't see any dice issues in say Can't Stop. It seems unique to the backgammon code.
I take it you don't read the Can't Stop forums then. Several similar discussions of "these dice rolls don't
feel like they should" are in there. Again, all without verifiable statistical analysis.