RANDOM Number Generation in C

Posted by CVS-2600Hertz-wordpress-com on Stack Overflow See other posts from Stack Overflow or by CVS-2600Hertz-wordpress-com
Published on 2010-04-19T10:26:16Z Indexed on 2010/04/19 10:33 UTC
Read the original article Hit count: 319

Filed under:
|
|

Recently i have begun development of a simple game. It is improved version of an earlier version that i had developed. Large part of the game's success depends on Random number generation in different modes:

MODE1 - Truly Random mode

myRand(min,max,mode=1);

  • Should return me a random integer b/w min & max.

MODE2 - Pseudo Random : Token out of a bag mode

myRand(min,max,mode=2);

  • Should return me a random integer b/w min & max. Also should internally keep track of the values returned and must not return the same value again until all the other values are returned atleast once.

MODE3 - Pseudo Random : Human mode

myRand(min,max,mode=3);

  • Should return me a random integer b/w min & max. The randomisation ought to be not purely mathematically random, rather random as user perceive it. How Humans see RANDOM.

* Assume the code is time-critical (i.e. any performance optimisations are welcome)

* Pseudo-code will do but an implementation in C is what i'm looking for.

* Please keep it simple. A single function should be sufficient (thats what i'm looking for)

Thank You

© Stack Overflow or respective owner

Related posts about c

    Related posts about random