• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Real random numbers

 
Greenhorn
Posts: 9
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

I was wondering, if I was to make a gambling game in java. Would it be a good idea to use the Random class to generate random number for cards ?
How do you guys generate real random numbers for games like that, so that the numbers or cards wouldn't be detectable.

Thank you
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you know, Random actually produces pseudorandom numbers; it uses a long as a seed, so there are not more than 2⁶⁴ different sequences of numbers possible. Are you going to use this commercially, or simply for entertainment purposes? I would be dubious if you were using it commercially, but if it is simply an exercise/entertainment, then Random should be all right. If you want to be strict about it, the maths can quickly get complicated. There is also SecureRandom.

Please search for random numbers and shuffling because there have been discussions about that elsewhere on the Ranch. Try here and here, and look for the references to Bloch and Gafter; there is more in the book than we can write here.
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're really driven towards absolute randomness, there's a web site that I tripped across a year or so ago that provides a network interface to a cesium (I think) based hardware random generator. Sorry, I don't remember the site.
 
Greenhorn
Posts: 5
Oracle Postgres Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:If you're really driven towards absolute randomness, there's a web site that I tripped across a year or so ago that provides a network interface to a cesium (I think) based hardware random generator. Sorry, I don't remember the site.



I think you're referring to https://www.random.org/
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
/dev/random Wikipedia
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic