needs random/gm
: randbyte rand temp tuck ! c@ ;
: 1or0 rand abs 0 do randbyte dup -1 > over 2 < and if unloop ;then drop loop 1or0 ;
: spec 1or0 drop 1 ;
: rand 1 ;
;-)
You may want to point out that you're writing Reva code, not ANS ...
Nice try, but that is definitely not enough Forth code. :)
That is true!
Ah, here's the same with "more Forth code":
1 CONSTANT rand-init
VALUE {rand}
: seed-rand rand-init TO {rand} ;
seed-rand
: rand {rand} ;
What was the purpose of "more Forth code" to output a constant, again?
I'm not sure I caught that part.
We might even get that AI singularity going!
DROP TUCK ROLL BYE
lol
>
> DROP TUCK ROLL BYE
Maybe he means that the random numbers are supposed to be triangularly
distributed. That is what my BIAS does (except leaning toward 0 rather
than toward the upper limit). All of this is in my novice package
(PRNG returns a pseudo-random cell value).
macro: rnd ( ulimit -- uvalue )
prng um* nip ;
macro: bias ( ulimit -- uvalue )
dup rnd over rnd um*
rot um/mod nip ;