Skip to content

Commit

Permalink
renamed rnd module to be more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyGaul committed Jun 19, 2024
1 parent ea3d667 commit 25b6db2
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 90 deletions.
16 changes: 8 additions & 8 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1199,18 +1199,18 @@ This is a list of all functions in Cute Framework organized by categories. This
## random

### functions
- [cf_rnd_next](/random/cf_rnd_next.md)
- [cf_rnd_next_double](/random/cf_rnd_next_double.md)
- [cf_rnd_next_float](/random/cf_rnd_next_float.md)
- [cf_rnd_next_range_double](/random/cf_rnd_next_range_double.md)
- [cf_rnd_next_range_float](/random/cf_rnd_next_range_float.md)
- [cf_rnd_next_range_int](/random/cf_rnd_next_range_int.md)
- [cf_rnd_next_range_uint64](/random/cf_rnd_next_range_uint64.md)
- [cf_rnd](/random/cf_rnd.md)
- [cf_rnd_double](/random/cf_rnd_double.md)
- [cf_rnd_float](/random/cf_rnd_float.md)
- [cf_rnd_range_double](/random/cf_rnd_range_double.md)
- [cf_rnd_range_float](/random/cf_rnd_range_float.md)
- [cf_rnd_range_int](/random/cf_rnd_range_int.md)
- [cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
- [cf_rnd_seed](/random/cf_rnd_seed.md)


### structs
- [CF_Rnd](/random/cf_rnd.md)
- [CF_RndState](/random/cf_rndstate.md)


## sprite
Expand Down
30 changes: 15 additions & 15 deletions docs/random/cf_rnd.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[](../header.md ':include')

# CF_Rnd
# cf_rnd

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

A random number generator.
Returns a random `uint64_t`.

Struct Members | Description
--- | ---
`uint64_t state[2]` | Just two `uint64_t`'s for the internal state. Very small! These are setup by [cf_rnd_seed](/random/cf_rnd_seed.md).

## Remarks
```cpp
uint64_t cf_rnd(CF_RndState* rnd);
```
A random number generator of the type LFSR (linear feedback shift registers). This specific
implementation uses the XorShift+ variation, and returns 64-bit random numbers. More information
can be found on Wikipedia.
https://en.wikipedia.org/wiki/Xorshift

This implementation comes from Mattias Gustavsson's single-file header collection.
https://github.com/mattiasgustavsson/libs/blob/main/rnd.h
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[cf_rnd_next](/random/cf_rnd_next.md)
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_double

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `double`.

```cpp
double cf_rnd_double(CF_RndState* rnd);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_float

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `float`.

```cpp
float cf_rnd_float(CF_RndState* rnd);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_range_double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_range_double

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `double` from the range `min` to `max` (inclusive).

```cpp
double cf_rnd_range_double(CF_RndState* rnd, double min, double max);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_range_float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_range_float

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `float` from the range `min` to `max` (inclusive).

```cpp
float cf_rnd_range_float(CF_RndState* rnd, float min, float max);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_range_int.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_range_int

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `int` from the range `min` to `max` (inclusive).

```cpp
int cf_rnd_range_int(CF_RndState* rnd, int min, int max);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
[cf_rnd_range_uint64](/random/cf_rnd_range_uint64.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rnd_range_uint64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# cf_rnd_range_uint64

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

Returns a random `uint64_t` from the range `min` to `max` (inclusive).

```cpp
uint64_t cf_rnd_range_uint64(CF_RndState* rnd, uint64_t min, uint64_t max);
```
Parameters | Description
--- | ---
rnd | The random number generator state.
## Related Pages
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
[cf_rnd](/random/cf_rnd.md)
[cf_rnd_float](/random/cf_rnd_float.md)
[cf_rnd_double](/random/cf_rnd_double.md)
[cf_rnd_range_int](/random/cf_rnd_range_int.md)
[cf_rnd_range_double](/random/cf_rnd_range_double.md)
[cf_rnd_range_float](/random/cf_rnd_range_float.md)
6 changes: 3 additions & 3 deletions docs/random/cf_rnd_seed.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/inc
Returns an initialized [CF_Rnd](/random/cf_rnd.md) based on an initial `seed` value.

```cpp
CF_Rnd cf_rnd_seed(uint64_t seed);
CF_RndState cf_rnd_seed(uint64_t seed);
```
Parameters | Description
Expand All @@ -23,5 +23,5 @@ deterministic way, so it's often important for many games to control or note whi
## Related Pages
[CF_Rnd](/random/cf_rnd.md)
[cf_rnd_next](/random/cf_rnd_next.md)
[CF_RndState](/random/cf_rndstate.md)
[cf_rnd](/random/cf_rnd.md)
28 changes: 28 additions & 0 deletions docs/random/cf_rndstate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[](../header.md ':include')

# CF_RndState

Category: [random](/api_reference?id=random)
GitHub: [cute_rnd.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h)
---

A random number generator.

Struct Members | Description
--- | ---
`uint64_t state[2]` | Just two `uint64_t`'s for the internal state. Very small! These are setup by [cf_rnd_seed](/random/cf_rnd_seed.md).

## Remarks

A random number generator of the type LFSR (linear feedback shift registers). This specific
implementation uses the XorShift+ variation, and returns 64-bit random numbers. More information
can be found on Wikipedia.
https://en.wikipedia.org/wiki/Xorshift

This implementation comes from Mattias Gustavsson's single-file header collection.
https://github.com/mattiasgustavsson/libs/blob/main/rnd.h

## Related Pages

[cf_rnd](/random/cf_rnd.md)
[cf_rnd_seed](/random/cf_rnd_seed.md)
Loading

0 comments on commit 25b6db2

Please sign in to comment.