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)
|
|
|
|
{
|
|
|
|
return (f32)((random_f32() * (max - min + 1)) + min);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s32
|
|
|
|
random_s32_in_range(s32 min, s32 max)
|
|
|
|
{
|
|
|
|
return (s32)((random_f32() * (max - min + 1)) + min);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
random_bool(void)
|
|
|
|
{
|
|
|
|
return random_s32_in_range(0, 2);
|
|
|
|
}
|
|
|
|
|