2024-08-30 01:47:29 +00:00
|
|
|
#include "random.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
random_seed_set(u64 seed)
|
|
|
|
{
|
|
|
|
jsw_seed(seed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
random_seed_time_set(void)
|
|
|
|
{
|
2024-08-30 02:16:35 +00:00
|
|
|
random_seed_set(jsw_time_seed());
|
2024-08-30 01:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
f32
|
|
|
|
random_f32(void)
|
|
|
|
{
|
|
|
|
return (f32)jsw_rand() / (f32)UINT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
f32
|
|
|
|
random_f32_in_range(f32 min, f32 max)
|
|
|
|
{
|
2024-08-30 05:18:18 +00:00
|
|
|
return (f32)((random_f32() * (max - min)) + min);
|
2024-08-30 01:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32
|
|
|
|
random_s32_in_range(s32 min, s32 max)
|
|
|
|
{
|
2024-08-30 05:18:18 +00:00
|
|
|
return (s32)((random_f32() * (max - min)) + min);
|
2024-08-30 01:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
random_bool(void)
|
|
|
|
{
|
|
|
|
return random_s32_in_range(0, 2);
|
|
|
|
}
|
|
|
|
|