|
@@ -1262,8 +1262,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STR
|
|
/**
|
|
/**
|
|
* Seed the pseudo-random number generator.
|
|
* Seed the pseudo-random number generator.
|
|
*
|
|
*
|
|
- * Reusing the seed number will cause SDL_rand() to repeat the same stream
|
|
|
|
- * of 'random' numbers.
|
|
|
|
|
|
+ * Reusing the seed number will cause SDL_rand() to repeat the same stream of
|
|
|
|
+ * 'random' numbers.
|
|
*
|
|
*
|
|
* \param seed the value to use as a random number seed, or 0 to use
|
|
* \param seed the value to use as a random number seed, or 0 to use
|
|
* SDL_GetPerformanceCounter().
|
|
* SDL_GetPerformanceCounter().
|
|
@@ -1282,13 +1282,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed);
|
|
*
|
|
*
|
|
* You likely want to use SDL_rand_n() to get a psuedo-randum number instead.
|
|
* You likely want to use SDL_rand_n() to get a psuedo-randum number instead.
|
|
*
|
|
*
|
|
- * If you want reproducible output, be sure to initialize with SDL_srand() first.
|
|
|
|
|
|
+ * If you want reproducible output, be sure to initialize with SDL_srand()
|
|
|
|
+ * first.
|
|
*
|
|
*
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
- * libraries available with different characteristics and you should pick one of
|
|
|
|
- * those to meet any serious needs.
|
|
|
|
|
|
+ * libraries available with different characteristics and you should pick one
|
|
|
|
+ * of those to meet any serious needs.
|
|
*
|
|
*
|
|
* \returns a random value in the range of [0-SDL_MAX_UINT32].
|
|
* \returns a random value in the range of [0-SDL_MAX_UINT32].
|
|
*
|
|
*
|
|
@@ -1306,21 +1307,20 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand(void);
|
|
* Generates a pseudo-random number less than n
|
|
* Generates a pseudo-random number less than n
|
|
*
|
|
*
|
|
* The method used is faster and of better quality than `SDL_rand() % n`.
|
|
* The method used is faster and of better quality than `SDL_rand() % n`.
|
|
- * However just like with `SDL_rand() % n`, bias increases with larger n.
|
|
|
|
- * Odds are better than 99.9% even for n under 1 million.
|
|
|
|
|
|
+ * However just like with `SDL_rand() % n`, bias increases with larger n. Odds
|
|
|
|
+ * are better than 99.9% even for n under 1 million.
|
|
*
|
|
*
|
|
- * Example: to simulate a d6 use `SDL_rand_n(6) + 1`
|
|
|
|
- * The +1 converts 0..5 to 1..6
|
|
|
|
|
|
+ * Example: to simulate a d6 use `SDL_rand_n(6) + 1` The +1 converts 0..5 to
|
|
|
|
+ * 1..6
|
|
*
|
|
*
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
- * libraries available with different characteristics and you should pick one of
|
|
|
|
- * those to meet any serious needs.
|
|
|
|
|
|
+ * libraries available with different characteristics and you should pick one
|
|
|
|
+ * of those to meet any serious needs.
|
|
*
|
|
*
|
|
- * \param n the number of possible values
|
|
|
|
- *
|
|
|
|
- * \returns a random value in the range of [0 .. n-1]
|
|
|
|
|
|
+ * \param n the number of possible values.
|
|
|
|
+ * \returns a random value in the range of [0 .. n-1].
|
|
*
|
|
*
|
|
* \threadsafety All calls should be made from a single thread
|
|
* \threadsafety All calls should be made from a single thread
|
|
*
|
|
*
|
|
@@ -1336,10 +1336,10 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_n(Uint32 n);
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* There are no guarantees as to the quality of the random sequence produced,
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* and this should not be used for security (cryptography, passwords) or where
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
* money is on the line (loot-boxes, casinos). There are many random number
|
|
- * libraries available with different characteristics and you should pick one of
|
|
|
|
- * those to meet any serious needs.
|
|
|
|
|
|
+ * libraries available with different characteristics and you should pick one
|
|
|
|
+ * of those to meet any serious needs.
|
|
*
|
|
*
|
|
- * \returns a random value in the range of [0.0, 1.0)
|
|
|
|
|
|
+ * \returns a random value in the range of [0.0, 1.0).
|
|
*
|
|
*
|
|
* \threadsafety All calls should be made from a single thread
|
|
* \threadsafety All calls should be made from a single thread
|
|
*
|
|
*
|