17 lines
425 B
Zig
17 lines
425 B
Zig
const std = @import("std");
|
|
|
|
var prng = std.rand.DefaultPrng.init(124346234556);
|
|
const rand = prng.random();
|
|
|
|
pub fn init() void {
|
|
var seed: u64 = undefined;
|
|
try std.posix.getrandom(std.mem.asBytes(&seed));
|
|
prng = std.rand.DefaultPrng.init(seed);
|
|
}
|
|
|
|
pub fn randMinMaxFloat(min: f32, max: f32) f32 {
|
|
var r1 = rand.float(f32);
|
|
r1 = 2 * (r1 - 0.5); //-0.5..0.5
|
|
return (@abs(min) + @abs(max)) / 2 * r1;
|
|
}
|