Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:38:32+00:00 2026-06-07T10:38:32+00:00

I am looking for a seeded random number generator that creates a pool of

  • 0

I am looking for a seeded random number generator that creates a pool of numbers as a context. It doesn’t have to be too good. It is used for a game, but it is important, that each instance of the Game Engine has its own pool of numbers, so that different game instances or even other parts of the game that use random numbers don’t break the deterministic character of the generated numbers.

Currently I am using rand() which obviously doesn’t have this feature.

Are there any c or objective-c generators that are capable of doing what I want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:38:35+00:00Added an answer on June 7, 2026 at 10:38 am

    Use srand to set the seed, and then use rand():

    unsigned int seed = 10;  /* Choose an arbitrary value for the seed */
    int r;
    
    srand(seed);             /* Set the seed                           */
    r = rand();              /* Generate a random number               */
    

    The man page explicitly states that the sequence of pseudo-random numbers can be repeatable (and hence it is deterministic):

    Thesrand() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by rand(). These sequences are repeatable by calling srand() with the same seed value.

    Edit (clarification):
    Note that the man page states that srand() is niether reentrant nor thread-safe.
    I assumed that by “different game instances” you meant different processes, in which case it is okay to use it.
    However, if you plan on changing seeds within the same process, you won’t get the functionality that you want. In this case I recommend using rand_r() instead. Take a look at this question for reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very basic random number function which generates a random number from
thanks for looking at my question. I have a long list of alternatives that
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking for best advice on how to do this: I have an insert like
Looking for a control that allows to select one text value at a time
Looking for a simple bit of JS to count the number of items in
I've been looking around but didn't find any members that seemed to let you
I am looking to find the most efficient way to create an application that
I have been looking for a simple way to allow a similar functionality to
I have been looking at manuals of the Zend search engine, but I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.