Code: Select all
Dim As Short x, y, c, r
Screen 12
Randomize , 4
Do
x = Int(Rnd(4) * 640)
y = Int(Rnd(4) * 480)
c = Int(Rnd(4) * 16)
r = Rnd(4)
PSet (x, y), c
Loop Until Len(InKey)
Code: Select all
Dim As Short x, y, c, r
Screen 12
Randomize , 4
Do
x = Int(Rnd(4) * 640)
y = Int(Rnd(4) * 480)
c = Int(Rnd(4) * 16)
r = Rnd(4)
PSet (x, y), c
Loop Until Len(InKey)
Code: Select all
Dim As Short x, y, c, r
Screen 12
Randomize , 4
Do
x = Int(Rnd() * 640)
y = Int(Rnd() * 480)
c = Int(Rnd() * 16)
r = Rnd()
PSet (x, y), c and 3
Loop Until Len(InKey)
jj2007 wrote:If you comment out the r=Rnd(4), it looks a lot more random. What is the role of that line?
Code: Select all
'Randomize , 4
for n as long=1 to 40
print rnd(4),rnd*4
next
sleep
Munair wrote:It forces the randomizer to stay within the range 0-4.
Yours truly wrote:My guess is that this phenomenon has nothing to do with the random number generator but is to do with graphics and I am now outside of my comfort zone.
Code: Select all
#include "crt.bi"
Dim As Short x, y, c, r
Screen 12
Randomize , 4
dim as long ac(16),ax(640),ay(480)
#macro Rd(n)
for z as long=1 to n+1
r+=rnd()
next
#endmacro
Do
x = Int(Rnd() * 640):ax(x)+=1
y = Int(Rnd() * 480):ay(y)+=1
c = Int(Rnd() * 16) :ac(c)+=1
Rd(8) '0,4,8, ....
PSet (x, y), c
Loop Until Len(InKey)
screen 0
width 120,900
print "num"," x"," y","c"
for n as long=0 to 640'16
print n,ax(n),iif(n<=480,str(ay(n))," "),iif(n<=16,str(ac(n))," ")
next
sleep
deltarho wrote:That is not correct. (4) is redundant.
Code: Select all
c = Int(Rnd() * 16)
Code: Select all
Dim As Short x, y, c, r
Dim As long ct
Screen 12
Randomize, 4
ct=0
Do
x = Int(Rnd() * 640)
y = Int(Rnd() * 480)
c = Int(Rnd() * 16)
r = Rnd()
PSet (x, y), c and 3
if ct < 30 Then
ct=ct+1
print ct, c, c and 3
if ct=30 Then Sleep
endif
Loop Until Len(InKey)
Code: Select all
Dim As Short x, y, c, r
Screen 12
Randomize , 4
Do
x = Int(Rnd * 4000)
y = Int(Rnd * 3000)
c = Int(Rnd * 16)
r = Int(Rnd * 16)
PSet (x, y), c + r
Loop Until Len(InKey)
Code: Select all
f(i+1) = (f(i) * &hFD43FD + &hC39EC3) and &hFFFFFF
Yours truly wrote:We may find this behaviour with any Linear Congruential Generator
Code: Select all
x(n+1) = (a*x(n) + c) Mod m
Code: Select all
Dim Shared z As Double
Function RandNR() As Double
z = ((1664525*z + 1013904223) Mod 4294967296)
Return z/4294967296 ' Normalise
End Function
Dim As Short x, y, c, r
Screen 12
z = 1234 ' Seed the generator
Do
x = Int(RandNR * 640)
y = Int(RandNR * 480)
c = Int(RandNR * 16)
r = RandNR
PSet (x, y), c
Loop Until Len(InKey)
deltarho wrote:We still have not got the answer, but are we getting any closer?
deltarho wrote:Strictly speaking counting_pine's formula is not a Linear Congruential Generator.
Code: Select all
f(i+1) = (f(i) * &hFD43FD + &hC39EC3) and &hFFFFFF
Users browsing this forum: No registered users and 1 guest