Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Simple Prng

Name: Anonymous 2014-05-13 1:00


// uses/requires a seed between 0 & 1
// returns values in range -1 to +1
function randout = sprng(n, seed, offset = 10)
randout = sin( ([1:n] .+ (offset + seed)) .^ 2.0 );
endfunction;

Name: Anonymous 2014-05-13 23:57

>>16
Indices should start at 1 though.

Name: Anonymous 2014-05-14 0:42

>>21
I agree, zero based is a holdover from low level languages where you have shit like pointer arithmetic. Any decently abstracted language will count the way humans do.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List