@iStrahan: Thanks. The gameLog alone deserve a donation! Cool stuff!
@LavitzBr: Thanks a lot. That’s what I am basically doing. I just wanted a more “algorithmic” way of doing that 
I also found this on Stackoverflow:
Assuming that you have a function p(n) that gives you the desired probability for a random number:
r = rand() // a random number between 0 and 1
for i in A to B do
if r < p(i)
return i
r = r - p(i)
done
http://stackoverflow.com/questions/13635448/generate-random-numbers-within-a-range-with-different-probabilities
A and B are the range of the random number you want (ie: A = 1, B =10) I guess p(n) is an array where you need to fill up with each category probability like:
p(1) = 0.5 – 50% chance for spawning a red ball
p(2) = 0.25 – 25% “”" yellow ball
p(3) = 0.05 – 5% “” green ball
p(4P = 0.02 – 2% “” blue ball
At least that’s the way I read it.
I guess in Lua, we could do something like this (NOT TESTED):
[lua]
p = {0.5,0.25,0.05,0.02}
A= 1
B =10
local function chance (A,B)
r = math.random()
for i = A,B do
if r < p(i) then
return i
else
r = r - p(i)
end
end
[/lua]
Please let me know if you see any errors!
Thanks a lot again guys. I think these time of random generation makes game more fun since you control how often an activity (enemies, powerups…) is generated.
Mo