petri_dish
diff Bacteria.py @ 2:02609649d88b
Bacteria.py module 0.1
author | Smirnova Victoria |
---|---|
date | Tue, 07 Dec 2010 21:26:34 +0300 |
parents | |
children | 6d2fde91e9c1 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Bacteria.py Tue Dec 07 21:26:34 2010 +0300 1.3 @@ -0,0 +1,23 @@ 1.4 +from random import* 1.5 + 1.6 +class Bacteria (object): 1.7 + def __init__ (self, position, velocity, lifetime, mutated): 1.8 + self.position=position 1.9 + self.velocity=velocity 1.10 + self.lifetime=lifetime 1.11 + self.mutated=mutated 1.12 + 1.13 + def check_collision (self, bacteria): 1.14 + for bact in bacteria: 1.15 + if 0<abs(self.position-bact.position)<3: 1.16 + return bact 1.17 + return false 1.18 + def reprod (type, env, p_max): 1.19 + if type=='s': 1.20 + p=1-p_max*(env/100) 1.21 + else: 1.22 + p=p_max*(env/100) 1.23 + return randrange(0, int(1/p))==0 1.24 + 1.25 + def asexual (self) 1.26 +