Random Python module and creating chances -


i have text adventure game battle system in place already. of course turn based, both player , enemy deal damage points (in float). use random.uniform() function generate attack points every round. 0 stands missing enemy or player. since use floats chance pretty slim. want create condition there let's chance 1 in 5 attack points equal 0.00. condition must run on every round.

how go it? there module use?

note: think use random module (random.randint(0,5)) wondering if there other way. thanks!

i think should use random.uniform() reserving 20% of values 0.00 attack points.

hit = random.uniform(0, 10) if hit <= 2:     damage = 0.00 else:     damage = (hit - 2) / 8 

this stupid example might help. or more simple:

hit = random.uniform(0, 10) if hit >= 8:     damage = 0.00 else:     damage = hit / 8 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -