Re: [Flashcoders] Math.random()
If this was connected to prizes/tournaments, from what I remember it depends on whether the user pays to play or not; and the laws of the country that your site is hosted in. From a UK perspective, if the user paid to play you'd need a gaming and/or gambling license (gaming for fixed-odds, gambling for games of skill - I assume Backgammon would come under the latter). I know that to get one of those licenses in the UK (for interactive TV gaming, which is why I'm being a bit woolly about the website thing) we needed to buy a much better random number generator. In fact - a hardware random number generator, with certification that we could show the authorities. This Wikipedia entry explains about hardware generators: http://en.wikipedia.org/wiki/Hardware_random_number_generator If your game isn't pay-to-play, I _think_ you'd be in the clear and could use whatever randomness your client was happy with; as essentially your client would be giving away stuff for free. If it is pay to play, you need to check it all out with the lawyers, I'm afraid. Hope that's helpful, Ian On 11/17/05, Dimitrios Bendilas [EMAIL PROTECTED] wrote: Hello, I have built a Backgammon game in Flash for a client. He is starting to ask questions about the randomness of the dice, because a registered member of the game said he's recorded the stats of about 100 backgammon games and found that the numbers generated are not so random. (I haven't seen the data, so I don't know if that's true) I know that Math.random() is not the best random generator in the world. I also know that a computer can never produce *really* random numbers. So, my question is this: Should I use some other algorithms for generating the value of the dice? Or Math.random() is really good enough? What if this game was connected to prizes, tournaments etc? Would I have to find something better then? Thank you ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Math.random()
He is starting to ask questions about the randomness of the dice, because a registered member of the game said he's recorded the stats of about 100 backgammon games and found that the numbers generated are not so random. (I haven't seen the data, so I don't know if that's true) I'd ask to see the data first - or record your own. There are plenty of tests you can make on frequencies and distribution: it's reasonably easy to work out what these should be for, say, 1000 numbers. Psychology plays a part here, and people tend to expect fewer clumps than they get. I know that Math.random() is not the best random generator in the world. I also know that a computer can never produce *really* random numbers. Actually, there are a few places where you can get genuinely random numbers, created from quantum events or noise in the world. Try http://www.random.org/, for example. So, my question is this: Should I use some other algorithms for generating the value of the dice? Or Math.random() is really good enough? What if this game was connected to prizes, tournaments etc? Would I have to find something better then? If it's connected to prizes, I wouldn't use random() directly (you'd be amazed how seriously people can take this kind of thing). You might want to try using bitmapData.noise or bitmapData.perlinNoise as a source of random data - you can even use some number like the time of a mousedown event as the random seed. I don't think Flash has any way to change the seed for the Math.random method. Danny ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Math.random()
The randomness of Math.random is one possible source of concern but what you do with the random number to produce a dice roll is more important. It is easy to make a simple mistake in the mapping of a random number to an integer between 1 and 6 that results in a skewed distribution. Gamblers always complain about dice rolls even if you use real dice. Do they have a specific complaint about the rolls - never getting any doubles - too many doubles - too many double-sixes, no rolls with 5 in them, always the same sequence of rolls?? If the complaint is that their opponent is always getting better rolls, you can fiddle with Math.random until you die of boredom and not fix the problem. What is the suspected or reported problem? Play a few games and record all of the rolls, put them in a spreadsheet and do some simple tests. A basic statistics book will tell you how to test the randomness. Looking for patterns is harder but if the players claim that there are repeated sequences, you should see them pretty easily. Ron Ian Thomas wrote: If this was connected to prizes/tournaments, from what I remember it depends on whether the user pays to play or not; and the laws of the country that your site is hosted in. From a UK perspective, if the user paid to play you'd need a gaming and/or gambling license (gaming for fixed-odds, gambling for games of skill - I assume Backgammon would come under the latter). I know that to get one of those licenses in the UK (for interactive TV gaming, which is why I'm being a bit woolly about the website thing) we needed to buy a much better random number generator. In fact - a hardware random number generator, with certification that we could show the authorities. This Wikipedia entry explains about hardware generators: http://en.wikipedia.org/wiki/Hardware_random_number_generator If your game isn't pay-to-play, I _think_ you'd be in the clear and could use whatever randomness your client was happy with; as essentially your client would be giving away stuff for free. If it is pay to play, you need to check it all out with the lawyers, I'm afraid. Hope that's helpful, Ian On 11/17/05, Dimitrios Bendilas [EMAIL PROTECTED] wrote: Hello, I have built a Backgammon game in Flash for a client. He is starting to ask questions about the randomness of the dice, because a registered member of the game said he's recorded the stats of about 100 backgammon games and found that the numbers generated are not so random. (I haven't seen the data, so I don't know if that's true) I know that Math.random() is not the best random generator in the world. I also know that a computer can never produce *really* random numbers. So, my question is this: Should I use some other algorithms for generating the value of the dice? Or Math.random() is really good enough? What if this game was connected to prizes, tournaments etc? Would I have to find something better then? Thank you ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Math.random()
On Nov 17, 2005, at 2:56 PM, Ron Wheeler wrote: If the game is for money and the client side code can be hacked for profit, you need to move more of the game engine onto the server and only present results and table state on the client side. Dice rolls can not be generated by the client in that case. Your client could be easily replaced by a version of your client that lets the player chose his own rolls which makes Backgammon not fun for the opponent but a really lucrative way to pass an afternoon for the guy choosing his rolls. You probably only need to chose 3 or 4 rolls during a game to win almost every time. (An interesting test on a real board for someone with time to kill and a friend who does not mind losing.) Ron Actually, part of the roll work can be done client-side. The issue is with the seed to any particular random number generator. One needs a secure hash of two generated keys from the server, then using a client-side random number algorithm with this key as the state input, this is completely possible. Check out my conversion of the mersenne twister algorithm for things like this (minus the crypto part with a server). The secure hash part is fairly easy to implement. Aside to this thread - never use Math.random() because it's inherently insecure. http://magicsnacks.com/shiftedpixels/?p=8 Jon Bradley Visual Effects / Interactive / Animation Post Central, Inc. [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Math.random()
You would not worry about someone being able to hack the client and modify the roll generation to allow the player to choose the desired roll and then send it (or the play result - move) to the server or just substitute the client with a client that lets rolls be specified? I am less worried about hacking the random number generator since if you want a double five it is going to be easier to specify that than to go to the trouble of specifying a random number that is going to generate a double six roll. I think that you want all play that should not be under control of the player to be done on the server. That way, there is no chance of a rogue client beating the system. Ron Jon Bradley wrote: On Nov 17, 2005, at 2:56 PM, Ron Wheeler wrote: If the game is for money and the client side code can be hacked for profit, you need to move more of the game engine onto the server and only present results and table state on the client side. Dice rolls can not be generated by the client in that case. Your client could be easily replaced by a version of your client that lets the player chose his own rolls which makes Backgammon not fun for the opponent but a really lucrative way to pass an afternoon for the guy choosing his rolls. You probably only need to chose 3 or 4 rolls during a game to win almost every time. (An interesting test on a real board for someone with time to kill and a friend who does not mind losing.) Ron Actually, part of the roll work can be done client-side. The issue is with the seed to any particular random number generator. One needs a secure hash of two generated keys from the server, then using a client-side random number algorithm with this key as the state input, this is completely possible. Check out my conversion of the mersenne twister algorithm for things like this (minus the crypto part with a server). The secure hash part is fairly easy to implement. Aside to this thread - never use Math.random() because it's inherently insecure. http://magicsnacks.com/shiftedpixels/?p=8 Jon Bradley Visual Effects / Interactive / Animation Post Central, Inc. [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders