< index < 9. Pseudorandom number generator < 9.2 Using a generator |
===================================== | > 9.4 Destroying a generator |
C++ : static int TCODRandom::getIntFromByteArray(int min, int max, const char *data,int len) C : int TCOD_random_get_int_from_byte_array(int min, int max, const char *data,int len) Py : random_get_int_from_byte_array(mi, ma, data)
Parameter | Description |
---|---|
min, max | When you call this function, you get a number between (including) min and max |
data, len | The byte array. len is the number of significant bytes in the array. data may not be finished by a 0 character. |
C++ : // get a random int from a name char *name = ... get a name int aRandomIntBetween0And1000 = TCODRandom::getIntFromByteArray(0,1000,name,(int)strlen(name)); // get a random int from another int int myInt = ... int aRandomInt = TCODRandom::getIntFromByteArray(0,1000,&myInt,sizeof(int)); C : /* get a random int from a name */ char *name = ... get a name int a_random_int_between_0_and_1000 = TCOD_random_get_int_from_byte_array(0,1000,name,(int)strlen(name)); /* get a random int from another int */ int my_int = ... int a_random_int = TCOD_random_get_int_from_byte_array(0,1000,&my_int,sizeof(int)); Py : # get a random int from a name name = ... get a name a_random_int_between_0_and_1000 = libtcod.random_get_int_from_byte_array(0,1000,name) # get a random int from another int my_int = ... a_random_int = libtcod.random_get_int_from_byte_array(0,1000,my_int)