Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re-seeding issue in FB
#1

I am attempting to implement re-seeding technigue. I posted the same at QB in General section. Mac suggested the code as below:
Code:
CLS
DO
  RANDOMIZE TIMER
  seed = RND * 999999
  y = RND(-seed)
  FOR i = 1 TO 5: PRINT RND; : NEXT i: PRINT
  y = RND(-seed)
  FOR i = 1 TO 5: PRINT RND; : NEXT i: PRINT
  INPUT "Again"; a$
LOOP WHILE LEFT$(UCASE$(a$ + " "), 1) = "Y"
CLS
SYSTEM

It works in QB but not so in FB. Any suggestion?

TIA Smile

Geo
Reply
#2
here's a fairly simple qb-rnd emulator function that will work with fb. it should be the same as qb's rnd output. (i haven't tested this very much, so watch out...)

Code:
declare function rnd2#(a as integer=0)

for i = 1 to 9
   a#=rnd2#
   print a#*16777216;a#
next
sleep

function rnd2#(a as integer=0) ' ***** ***** This is the number produced by zombie
static seed#,ft as byte
if ft=0 then seed#=327680:ft=1
if a<>0 then
   if a=abs(a) then seed#=(seed#+a) mod 16777216 else seed#=-a
end if
Temp# = (16598013# * Seed# + 12820163)
Seed# = Temp# - INT(Temp# / 16777216) * 16777216
rnd2#=seed#/16777216
end function
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#3
actually, fb's randomize statement works different that qb's, so you could just say
Code:
CLS
DO
  RANDOMIZE TIMER
  seed = RND * 999999
  RANDOMIZE seed
  FOR i = 1 TO 5: PRINT RND; : NEXT i: PRINT
  RANDOMIZE seed
  FOR i = 1 TO 5: PRINT RND; : NEXT i: PRINT
  INPUT "Again"; a$
LOOP WHILE LEFT$(UCASE$(a$ + " "), 1) = "Y"
CLS
SYSTEM
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#4
Thanks, dumbledore!

I prefer your second version. The code looks more sense and cleaner than that of QB version.

Geo
Reply
#5
Yeah, as shown at docs/keywords.txt, negative arguments with RND have no means in FB.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)