Closed sadger closed 10 years ago
My brain isn't working I got the calculation wrong :-1: I'll amend the code in the new branch to reflect this change.
I am not sure mine is any better!
Would this be any better?
local potentially_contagious = contRate and math.random(1,contRate) == contRate
That would give you 1% chance range(1,contRate) is the same as 100/ContRate so we can just leave it :P
Why 1%? If contrate is 10 there is a one in ten chance and if it is 40 there is a one in forty
Because you use "==" if contrate is X then there is only one value that makes that true in the range(1,100) which is X itself so have 1/100 chance hence 1%. If you used >= then you get the same as 100/ContRate.
How is the range the range(1,100)? contrate is the value in the level file, if you entered 100 then you would get math.random(1, 100) because you wanted a low chance, but if you entered 10 you wanted a higher chance. So math.random(1, 10) surely.
Sorry I misunderstood your idea assuming we were still talking about a random value between 1 and 100. Your idea works nicely and is a lot clearer, i'll change it to that and we'll see how it works out. Make sure to be using the new branch :)
That doesn't work as there is an empty interval error Try local potentially_contagious = contRate > 0 and (math.random(1,contRate) == contRate) I suppose if contrate was 0 you would end up with (1, 0)
Ah yes that is true, at least one of our brains is working today! Maybe I need coffee! Thanks for the input!
ContRate has been modified to your suggestion @MarkL1961 we'll see if it works. I'll close this issue for now as i'm pretty sure it's correct. Hopefully it may cause a bit more spreading but probably not enough.
In the current implemention ContRate% of people are make contagious when in the original it was 1/ContRate - a big difference in some cases, changing this will hopefully help with issue #1.
From MarkL in the main thread