Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Numbers
#1
Make a random number generator that doesn't use RND... Have Fun!
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
Crappy but working Wink

Code:
DECLARE FUNCTION MyRandom% (Bottom%, Top%)
DIM SHARED seed%

seed% = 0

FOR i& = 0 TO 100000
   PRINT MyRandom%(0, 100);
NEXT

FUNCTION MyRandom% (Bottom%, Top%)
   Range% = Top% - Bottom%
   IF seed% < 1000 THEN seed% = 1000
   value& = seed% \ 35: seed% = (value& * 37) AND 32767
   t% = value& MOD Range%
   MyRandom% = t% + Bottom%
END FUNCTION
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Interesting... but it is a pattern. If you could make it start in the a different place that would be cool.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
Code:
DEFLNG A-Z
a = TIMER
FOR j = 1 to 10
  M = 10000
  M1 = 100
  b = 7821
  p1 = a \ M1
  p0 = a MOD M1
  q1 = B \ M1
  q0 = B MOD M1
  c = (((p0 * q1 + p1 * q0) MOD M1) * M1 + p0 * q0) MOD M
  a = (c + 1) MOD M
  g = a \ M1
  PRINT g
NEXT

(QBNews, Volume 2, Number 1 - February 28, 1991)
Tongue
Reply
#5
Given a certain sequence of numbers [S], it has so far been difficult to create another two sequences [S1] and [S2] that represent the first sequence and a decoder with C being at its maximum in:

length[S] = length[S1] + length[S2] + C

Another difficult problem would be to find a sequence [S]. where sequence [S1a] and decoder [S2a] are the only two possible solutions to length[S] = length[S1] + length[S2] + C.

So, making a "true" random number sequence (one without any pattern) is really hard if not impossible. :")
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
I think Plasma357's works!

Edit:

Heres one that picks a number 1 through 100...
Code:
CLS
INPUT "Input max ", x
a$ = STR$(TIMER)
IF LEN(a$) < 7 THEN a$ = a$ + "0"
a$ = RIGHT$(a$, 2)
a = VAL(a$)
DO
IF a > x THEN a = a - x
IF a <= x THEN EXIT DO
LOOP
PRINT a
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#7
Quote:So, making a "true" random number sequence (one without any pattern) is really hard if not impossible. :")

Don't crack your head, RND uses patterns too. At least in QB.
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#8
I hear that nuclear decay can produce true random numbers somehow... anybody got a nuke in their backyard? Just hook it up to a COM port and write a QB app... :wink:
Reply
#9
Quote:I hear that nuclear decay can produce true random numbers somehow... anybody got a nuke in their backyard? Just hook it up to a COM port and write a QB app... :wink:

Nope. Nuclear decay means in itself a patterned decay.

ie: Val=Val-Val/2

BTW, val would be you elemental lifespan. Find "HalfLife" in the dictionary.
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#10
Whoops... radioactive decay, not nuke.

see http://www.nea.fr/abs/html/nesc0843.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)