sadger / CorsixTH

Open source clone of Theme Hospital
Other
1 stars 0 forks source link

ContRate uses wrong value #3

Closed sadger closed 10 years ago

sadger commented 10 years ago

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

ContRate - Is this a Contagious Illness (1/ContRate are contagious)

So 10 means 1/10 and 40 means 1/40 so the higher the number the lesser the chance of being contagious!
Look at level 6 and this seems to be the case as those numbers are lower than other levels but this is the level with more chances of epidemics

so is this line correct?

local potentially_contagious = contRate and contRate >= math.random(1,100)

or should it be

local potentially_contagious = contRate and (100 / contRate) >= math.random(1,100)
sadger commented 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.

MarkL1961 commented 10 years ago

I am not sure mine is any better!
Would this be any better? local potentially_contagious = contRate and math.random(1,contRate) == contRate

sadger commented 10 years ago

That would give you 1% chance range(1,contRate) is the same as 100/ContRate so we can just leave it :P

MarkL1961 commented 10 years ago

Why 1%? If contrate is 10 there is a one in ten chance and if it is 40 there is a one in forty

sadger commented 10 years ago

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.

MarkL1961 commented 10 years ago

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.

sadger commented 10 years ago

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 :)

MarkL1961 commented 10 years ago

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)

sadger commented 10 years ago

Ah yes that is true, at least one of our brains is working today! Maybe I need coffee! Thanks for the input!

sadger commented 10 years ago

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.