< index < 9. Pseudorandom number generator |
===================================== | > 9.2 Using a generator |
C++ : static TCODRandom *TCODRandom::getInstance() C : TCOD_random_t TCOD_random_get_instance() Py : random_get_instance()
C++ : TCODRandom::TCODRandom() C : TCOD_random_t TCOD_random_new() Py : random_new()
C++ : TCODRandom::TCODRandom(uint32 seed); C : TCOD_random_t TCOD_random_new_from_seed(uint32 seed);
Parameter | Description |
---|---|
seed | The 32 bits seed used to initialize the generator. Two generators created with the same seed will generate the same set of pseudorandom numbers. |
C++ : // default generator TCODRandom * default = TCODRandom::getInstance(); // another random generator TCODRandom *myRandom = new TCODRandom(); // a random generator with a specific seed TCODRandom *myDeterministRandom = new TCODRandom(0xdeadbeef); C : /* default generator */ TCOD_random_t default = TCOD_random_get_instance(); /* another random generator */ TCOD_random_t my_random = TCOD_random_new(); /* a random generator with a specific seed */ TCOD_random_t my_determinist_random = TCOD_random_new_from_seed(0xdeadbeef); Py : # default generator default = libtcod.random_get_instance() # another random generator my_random = libtcod.random_new() # a random generator with a specific seed my_determinist_random = libtcod.random_new_from_seed(0xdeadbeef)