Name: Anonymous 2010-10-07 22:14
hma = math.random(1, 1000)
if hma < 500 then
print "HAX MY ANUS!"
else
print "HAX MY ANUS!"
end
hma = math.random(1, 1000)
if hma < 500 then
print "HAX MY ANUS!"
else
print "HAX MY ANUS!"
end
range(1, 5) returns [1, 2, 3, 4] and notably not 5). Lua isn't one of these languages, so >>1's code will return 1000 values, and not 999 as >>9 seems to expect. As for the actual range and odds of each branch, the split is between values 1...499 and 500...1000, which are respectively 499 and 501 elements. Therefore, the two branches have (assuming a completely fair random algorithm) 49.9% and 50.1% execution probability.
math.random is half-inclusive.
> t = {}; for n = 1, 1000 do table.insert(t, math.random(1, 3)) end; table.sort(t); table.sort(t); print(table.concat(t, ''))
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333