• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Random Numbers

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm wondering if there's anyway to get Java's random number generator to generate the same sequence of numbers as C's srand and rand? That is, if I were to call C's srand() with a seed of 100 and create a new Random object in java with a seed of 100 and then use, in C, rand() and, in Java, nextInt() how can I get the same sequence of numbers from Java as I would from C? Is it even possible?

For those wondering, I'm trying to create a modified version of FreeCell and I want to have the games be the same as in the Microsoft version, which uses the random number generator in C to generate the card order in the games.

Thanks,
Jeff
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would guess that there isn't a single c-random-implementation, but different ones from borland, intel, gnu, ...
Some of them aren't open-source, but chances aren't bad, that the algorithm is documented, since a lot of users are interested.

So I guess you have to find out, which library is/ was used with your freecell, and reimplement it with java on your own.
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic