back

by emptybits·9y ago·view on hn ↗
What you describe (non-linear) would probably have been superior but in my youth and inexperience over 15 years ago (and pressed with time and code-size constraints) I am sure I did nothing more than a scalar, maybe clamped with a C macro MAX() or MIN(). Sorry to disappoint; sometimes game AI and sim work just needs to be "good enough" and ... most importantly, needs to ship on time (on shelves, yes shelves, X weeks before opening day of baseball season) with zero bugs (no online patches in those days). So there is a certain satisfaction in that. :-)
1 comments
Thanks for the reply.

I came up with:

f(x) = (sin((pi * x) - (pi / 2)) + 1) / 2 where x is between 0 and 1

I'm a collector of randomness functions for games. Weighted, gaussian, linear, etc. This sinusoidal randomness will be handy! Thanks for the inspiration.