I have two instances called and running. They interact with each other and I would like one of the instances to cease to exist in the second round based on a given condition. How do you kill an instance?
The code is below. I have Red and Yellow as my instances and I want them to die when life = 0 and not show up in the preceding rounds of the game. Thank you. Ara CODE HERE: ########################################################################## #Red and Yellow yeast model # #Both yeast start out cooperating. #If the yeast detect that there is no ade or lys present they will defect #but die. ########################################################################## import time chemicals = [] #0 cooperates #1 defects class RedYeast: #Needs adenine to grow, releases lysine def __init__(self,name,group): self.name = name self.group = group self.life = 1 self.hate_tolerance = 0 self.choice = 0 #METHODS def lys_re(self,stuffa): #release of lys in the environment if self.choice == 0: print self.name, "-- Releasing lys" chemicals.append(stuffa) elif self.choice == 1: print self.name, "-- Withholds lys" def ade_need(self,stuffb): if stuffb != chemicals: print self.name,"is taking ade" self.life = self.life+1 chemicals.remove(stuffb) print chemicals print "Life", self.life else: print "No ade presents" self.life = self.life-1 self.choice = 1 class YellowYeast: #Needs lysine to grow, releases adenine def __init__(self,name,group): self.name = name self.group = group self.life = 1 self.hate_tolerance = 0 self.choice = 0 #METHODS def ade_re(self,stuffa): #release of lys in the environment if self.choice == 0: print self.name, "-- Releasing ade" chemicals.append(stuffa) elif self.choice == 1: print self.name, "-- Withholds ade" def lys_need(self,stuffb): if stuffb != chemicals: print self.name," is taking ade" self.life = self.life+1 chemicals.remove(stuffb) print chemicals print "Life",self.life print else: print "No ade presents" self.life = self.life-1 self.choice = 1 def death(self): ############################################################## #Start of program ############################################################## rounds = raw_input("How many rounds to you wish to play through?") print "Starting environment", chemicals rounds =int(rounds) count = 0 #Creates the instances for RedYeast and YellowYeast one = RedYeast("Red","alpha") two = YellowYeast("Yellow","alpha") #Game logic while count < rounds: print "##################################################" print one.lys_re("lys") two.ade_re("ade") print print "Chemicals in the environment",chemicals print time.sleep(1) one.ade_need("ade") two.lys_need("lys") print "##################################################" print count = count+1 print "Ending environment", chemicals -- Quis hic locus, quae regio, quae mundi plaga. Ubi sum. Sub ortu solis an sub cardine glacialis ursae. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor