Quote:
r=rand(max=8,seed=true)+1 # Int, Range 1 to 9
version()
Subtitle(String(r), align=r) # Align=0 is illegal, 10 too.
|
Not quite.
Code:
BINGOS=0
Rand(seed=true)
For(i=1,50) {
r=Rand(Max=8)+1 # Int, range 1 to 8
BINGOS=(r==9)?BINGOS+1:BINGOS
RT_DebugF("%d] %d %s",i,r,r==9?"BINGO":"")
}
RT_DebugF("\nNumber of 9's = %d",BINGOS)
return version
Code:
00000005 1.23400939 RT_DebugF: 1] 2
00000006 1.23405778 RT_DebugF: 2] 7
00000007 1.23410249 RT_DebugF: 3] 1
00000008 1.23414886 RT_DebugF: 4] 4
00000009 1.23418772 RT_DebugF: 5] 6
00000010 1.23423040 RT_DebugF: 6] 7
00000011 1.23427629 RT_DebugF: 7] 5
00000012 1.23431504 RT_DebugF: 8] 8
00000013 1.23435771 RT_DebugF: 9] 2
00000014 1.23440421 RT_DebugF: 10] 5
...
00000044 1.23567069 RT_DebugF: 40] 4
00000045 1.23570931 RT_DebugF: 41] 8
00000046 1.23575175 RT_DebugF: 42] 1
00000047 1.23579741 RT_DebugF: 43] 4
00000048 1.23583603 RT_DebugF: 44] 6
00000049 1.23587847 RT_DebugF: 45] 4
00000050 1.23592424 RT_DebugF: 46] 4
00000051 1.23596275 RT_DebugF: 47] 2
00000052 1.23600531 RT_DebugF: 48] 4
00000053 1.23605096 RT_DebugF: 49] 2
00000054 1.23608959 RT_DebugF: 50] 5
00000055 1.23612595 RT_DebugF:
00000057 1.23616958 RT_DebugF: Number of 9's = 0
nuther one
Code:
ColorBars.KillAudio.ShowFrameNumber
Rand(seed=true) # seed only once (As 'Randomize()' in other languages)
Global BINGOS=0
SSS="""
n=current_frame
r=rand(max=9)+1 # Int, Range 1 to 9
Global BINGOS=(r==9)?BINGOS+1:BINGOS
RT_DebugF("%d] %d",n,r)
Subtitle(String(n,"%.0f]")+String(BINGOS," BINGOS=%.0f : ")+String(r,"R=%.0f"), align=r) # Align=0, is illegal
return last
"""
return ScriptClip(SSS)
EDIT: Results of Rand(
max) are modulo
max. [The remainder after SomeBigNumber / max]
Quote:
Rand
Rand([int max] [, bool scale] [, bool seed])
Returns a random integer value. All parameters are optional.
max
sets the maximum value+1 (default 32768) and can be set negative for negative results. It operates either in scaled or modulus mode (default scale=true only if Abs(max) > 32768, false otherwise).
|
Code:
Rand(max=n) # Range 0 to n-1
Rand(max=n)+1 # Range 1 to n