home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
RANDOM.ARC
/
BASIC.LST
next >
Wrap
File List
|
1990-07-21
|
2KB
|
68 lines
STANDALONE MS BASIC VERSION OF LISTING 1
10 PRINT "whbasic - 840930"
20 PRINT "basic version of Wichmann Hill generator"
30 REM J C Nash
40 REM x, y and z must be seeded as per article
50 PRINT "provide 3 integers as seeds to the generator"
60 PRINT "seed x=";
70 INPUT X
80 REM adjuust to be in range [0, 30269]
90 IF X = 0 THEN 120
100 LET X=X+30269
110 GOTO 90
120 IF X=30269 THEN 160
130 LET X=INT (X-30269)
140 GOTO 120
150 REM note use of int to ensure integer seed
160 PRINT "seed y=";
170 INPUT Y
180 REM adjust to be in range [0, 30307]
190 IF Y = 0 THEN 220
200 LET Y = Y+30307
210 GOTO 190
220 IF Y=30307 THEN 260
230 LET Y = INT (Y-30307)
240 GOTO 220
250 REM note use of int to ensure integer seed
260 PRINT "seed z=";
270 REM ADJUST TO BE IN RANGE [O, 30323]
280 IF Z = 0 THEN 310
290 LET Z=Z+30323
300 IF Z=30323 THEN 350
320 LET Z=INT (Z-30323)
330 GOTO 310
340 REM note use of int to ensure integer seed
350 INPUT Z
360 PRINT
370 PRINT "how many numbers are to be generated";
380 INPUT N
390 FOR I = 1 TO N
400 GOSUB 1000
410 PRINT
420 PRINT "current values -- x=";X;" y=";Y;" x=";Z
430 PRINT " random fraction =";R
440 NEXT I
450 STOP
1000 REM comput next member of pseudo-random sequence
1010 LET X1=INT(X/177)
1020 LET X2=X-177*X1
1030 LET X=171*X2-2*X1
1040 IF X < 0 THEN LET X=X+30269
1050 LET Y1=INT (Y/176)
1060 LET Y2=Y-176*Y1
1070 LET Y=172*Y2-35*Y1
1080 IF Y < 0 THEN LET Y =Y+30307
1090 LET Z1=INT(Z/178)
1100 LET Z2=Z-178*Z1
1110 LET Z=170*Z2-63*Z1
1120 IF Z < 0 THEN LET Z=Z+30323
1130 REM combine generators to give function
1140 LET T=X/30269+Y/30307+Z/30323
1150 LET R=T-INT(T)
1160 REM get fractional part of t only
1170 RETURN