AERMRE 1.5.1
AER modding framework for Hyper Light Drifter.
|
Utilities for generating pseudorandom numbers. More...
Go to the source code of this file.
Typedefs | |
typedef void | AERRandGen |
Opaque type for a self-managed pseudorandom number generator. More... | |
Functions | |
uint64_t | AERRandUInt (void) |
Get a pseudorandom unsigned integer on the interval [0, 2^64) using the automatically-seeded global generator. More... | |
uint64_t | AERRandUIntRange (uint64_t min, uint64_t max) |
Get a pseudorandom unsigned integer on the interval [min, max) using the automatically-seeded global generator. More... | |
int64_t | AERRandInt (void) |
Get a pseudorandom signed integer on the interval [-2^63, 2^63) using the automatically-seeded global generator. More... | |
int64_t | AERRandIntRange (int64_t min, int64_t max) |
Get a pseudorandom signed integer on the interval [min, max) using the automatically-seeded global generator. More... | |
float | AERRandFloat (void) |
Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) using the automatically-seeded global generator. More... | |
float | AERRandFloatRange (float min, float max) |
Get a pseudorandom floating-point value on the interval [min, max) using the automatically-seeded global generator. More... | |
double | AERRandDouble (void) |
Get a pseudorandom double floating-point value on the interval [0.0, 1.0) using the automatically-seeded global generator. More... | |
double | AERRandDoubleRange (double min, double max) |
Get a pseudorandom double floating-point value on the interval [min, max) using the automatically-seeded global generator. More... | |
bool | AERRandBool (void) |
Get a pseudorandom boolean using the automatically-seeded global generator. More... | |
void | AERRandShuffle (size_t elemSize, size_t bufSize, void *elemBuf) |
Shuffle an array of arbitrary elements using the automatically-seeded global generator. More... | |
AERRandGen * | AERRandGenNew (uint64_t seed) |
Allocate and initialize a new self-managed pseudorandom number generator. More... | |
void | AERRandGenFree (AERRandGen *gen) |
Free a self-managed pseudorandom number generator allocated using AERRandGenNew. More... | |
void | AERRandGenSeed (AERRandGen *gen, uint64_t seed) |
Re-seed a self-managed pseudorandom number generator. More... | |
uint64_t | AERRandGenUInt (AERRandGen *gen) |
Get a pseudorandom unsigned integer on the interval [0, 2^64) using a self-managed generator. More... | |
uint64_t | AERRandGenUIntRange (AERRandGen *gen, uint64_t min, uint64_t max) |
Get a pseudorandom unsigned integer on the interval [min, max) using a self-managed generator. More... | |
int64_t | AERRandGenInt (AERRandGen *gen) |
Get a pseudorandom signed integer on the interval [-2^63, 2^63) using a self-managed generator. More... | |
int64_t | AERRandGenIntRange (AERRandGen *gen, int64_t min, int64_t max) |
Get a pseudorandom signed integer on the interval [min, max) using a self-managed generator. More... | |
float | AERRandGenFloat (AERRandGen *gen) |
Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) using a self-managed generator. More... | |
float | AERRandGenFloatRange (AERRandGen *gen, float min, float max) |
Get a pseudorandom floating-point value on the interval [min, max) using a self-managed generator. More... | |
double | AERRandGenDouble (AERRandGen *gen) |
Get a pseudorandom double floating-point value on the interval [0.0, 1.0) using a self-managed generator. More... | |
double | AERRandGenDoubleRange (AERRandGen *gen, double min, double max) |
Get a pseudorandom double floating-point value on the interval [min, max) using a self-managed generator. More... | |
bool | AERRandGenBool (AERRandGen *gen) |
Get a pseudorandom boolean using a self-managed generator. More... | |
void | AERRandGenShuffle (AERRandGen *gen, size_t elemSize, size_t bufSize, void *elemBuf) |
Shuffle an array of arbitrary elements using a self-managed generator. More... | |
Utilities for generating pseudorandom numbers.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
typedef void AERRandGen |
Opaque type for a self-managed pseudorandom number generator.
Use this with the functions prefixed with AERRandGen...
bool AERRandBool | ( | void | ) |
Get a pseudorandom boolean using the automatically-seeded global generator.
double AERRandDouble | ( | void | ) |
Get a pseudorandom double floating-point value on the interval [0.0, 1.0) using the automatically-seeded global generator.
double AERRandDoubleRange | ( | double | min, |
double | max | ||
) |
Get a pseudorandom double floating-point value on the interval [min, max) using the automatically-seeded global generator.
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0.0
if unsuccessful.AER_BAD_VAL | if argument min is greater than or equal to argument max . |
float AERRandFloat | ( | void | ) |
Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) using the automatically-seeded global generator.
float AERRandFloatRange | ( | float | min, |
float | max | ||
) |
Get a pseudorandom floating-point value on the interval [min, max) using the automatically-seeded global generator.
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0.0f
if unsuccessful.AER_BAD_VAL | if argument min is greater than or equal to argument max . |
bool AERRandGenBool | ( | AERRandGen * | gen | ) |
Get a pseudorandom boolean using a self-managed generator.
[in] | gen | Generator of interest. |
false
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
double AERRandGenDouble | ( | AERRandGen * | gen | ) |
Get a pseudorandom double floating-point value on the interval [0.0, 1.0) using a self-managed generator.
[in] | gen | Generator of interest. |
0.0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
double AERRandGenDoubleRange | ( | AERRandGen * | gen, |
double | min, | ||
double | max | ||
) |
Get a pseudorandom double floating-point value on the interval [min, max) using a self-managed generator.
[in] | gen | Generator of interest. |
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0.0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
AER_BAD_VAL | if argument min is greater than or equal to argument max . |
float AERRandGenFloat | ( | AERRandGen * | gen | ) |
Get a pseudorandom floating-point value on the interval [0.0f, 1.0f) using a self-managed generator.
[in] | gen | Generator of interest. |
0.0f
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
float AERRandGenFloatRange | ( | AERRandGen * | gen, |
float | min, | ||
float | max | ||
) |
Get a pseudorandom floating-point value on the interval [min, max) using a self-managed generator.
[in] | gen | Generator of interest. |
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0.0f
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
AER_BAD_VAL | if argument min is greater than or equal to argument max . |
void AERRandGenFree | ( | AERRandGen * | gen | ) |
Free a self-managed pseudorandom number generator allocated using AERRandGenNew.
[in] | gen | Generator of interest. |
AER_NULL_ARG | if argument gen is NULL . |
int64_t AERRandGenInt | ( | AERRandGen * | gen | ) |
Get a pseudorandom signed integer on the interval [-2^63, 2^63) using a self-managed generator.
[in] | gen | Generator of interest. |
0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
int64_t AERRandGenIntRange | ( | AERRandGen * | gen, |
int64_t | min, | ||
int64_t | max | ||
) |
Get a pseudorandom signed integer on the interval [min, max) using a self-managed generator.
This function has been carefully designed to avoid introducing any distribution-related bias. For faster but potentially biased generation, use modulo.
[in] | gen | Generator of interest. |
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
AER_BAD_VAL | if argument min is greater than or equal to argument max . |
AERRandGen * AERRandGenNew | ( | uint64_t | seed | ) |
Allocate and initialize a new self-managed pseudorandom number generator.
When no longer needed, free this generator using AERRandGenFree.
[in] | seed | Initial generator seed. |
void AERRandGenSeed | ( | AERRandGen * | gen, |
uint64_t | seed | ||
) |
Re-seed a self-managed pseudorandom number generator.
[in] | gen | Generator of interest. |
[in] | seed | New generator seed. |
AER_NULL_ARG | if argument gen is NULL . |
void AERRandGenShuffle | ( | AERRandGen * | gen, |
size_t | elemSize, | ||
size_t | bufSize, | ||
void * | elemBuf | ||
) |
Shuffle an array of arbitrary elements using a self-managed generator.
[in] | gen | Generator of interest. |
[in] | elemSize | Size of each buffer element in bytes. |
[in] | bufSize | Size of buffer in elements. |
[in,out] | elemBuf | Buffer of elements to shuffle. |
AER_BAD_VAL | if argument elemSize is 0 . |
AER_NULL_ARG | if either argument gen or elemBuf is NULL . |
uint64_t AERRandGenUInt | ( | AERRandGen * | gen | ) |
Get a pseudorandom unsigned integer on the interval [0, 2^64) using a self-managed generator.
[in] | gen | Generator of interest. |
0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
uint64_t AERRandGenUIntRange | ( | AERRandGen * | gen, |
uint64_t | min, | ||
uint64_t | max | ||
) |
Get a pseudorandom unsigned integer on the interval [min, max) using a self-managed generator.
This function has been carefully designed to avoid introducing any distribution-related bias. For faster but potentially biased generation, use modulo.
[in] | gen | Generator of interest. |
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0
if unsuccessful.AER_NULL_ARG | if argument gen is NULL . |
AER_BAD_VAL | if argument min is greater than or equal to argument max . |
int64_t AERRandInt | ( | void | ) |
Get a pseudorandom signed integer on the interval [-2^63, 2^63) using the automatically-seeded global generator.
int64_t AERRandIntRange | ( | int64_t | min, |
int64_t | max | ||
) |
Get a pseudorandom signed integer on the interval [min, max) using the automatically-seeded global generator.
This function has been carefully designed to avoid introducing any distribution-related bias. For faster but potentially biased generation, use modulo.
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0
if unsuccessful.AER_BAD_VAL | if argument min is greater than or equal to argument max . |
void AERRandShuffle | ( | size_t | elemSize, |
size_t | bufSize, | ||
void * | elemBuf | ||
) |
Shuffle an array of arbitrary elements using the automatically-seeded global generator.
[in] | elemSize | Size of each buffer element in bytes. |
[in] | bufSize | Size of buffer in elements. |
[in,out] | elemBuf | Buffer of elements to shuffle. |
AER_BAD_VAL | if argument elemSize is 0 . |
AER_NULL_ARG | if argument elemBuf is NULL . |
uint64_t AERRandUInt | ( | void | ) |
Get a pseudorandom unsigned integer on the interval [0, 2^64) using the automatically-seeded global generator.
uint64_t AERRandUIntRange | ( | uint64_t | min, |
uint64_t | max | ||
) |
Get a pseudorandom unsigned integer on the interval [min, max) using the automatically-seeded global generator.
This function has been carefully designed to avoid introducing any distribution-related bias. For faster but potentially biased generation, use modulo.
[in] | min | Minimum possible value (inclusive). |
[in] | max | Maximum possible value (exclusive). |
0
if unsuccessful.AER_BAD_VAL | if argument min is greater than or equal to argument max . |