Example #1
0
 def growSeedOnPlant(self, maxCarbonForSeed):
     if maxCarbonForSeed > self.motherPlant.massSeedMax:
         maxCarbonForSeed =self.motherPlant.massSeedMax
     if not self.motherPlant.massFixed==-0.0:
         if maxCarbonForSeed>self.motherPlant.massFixed:
             maxCarbonForSeed=self.motherPlant.massFixed
     self.motherPlant.massFixed=self.motherPlant.massFixed-maxCarbonForSeed
     self.massSeed= self. massSeed + maxCarbonForSeed
     #use that value to calculate the radius of the seed
     #convert mass to volume and the get the radius
     i= self.massSeed/self.densitySeed #this is volume in m^3
     #i=i/(4.0/3.0)
     i=i/1.3333
     #i=i/(math.pi)
     i=i/3.14
     #i=math.pow(i, 1.0/3.0)
     #i=math.pow(i, 0.3333)
     i=i**0.3333
     self.radiusSeed=i
     
     ###need to move the seed as the plant grows###
     if self.motherPlant.leafIsHemisphere:
         dist=geometry_utils.distBetweenPoints(self.x, self.y, self.motherPlant.x, self.motherPlant.y)
         if dist==self.motherPlant.radiusLeaf:
             deltaY=self.motherPlant.radiusLeaf
         elif dist==0.0:
             deltaY=0.0
         else:
             deltaY=self.motherPlant.radiusLeaf-((abs((self.motherPlant.radiusLeaf*self.motherPlant.radiusLeaf)-(dist*dist)))**0.5)
         seedZ=self.motherPlant.heightStem+(self.motherPlant.heightLeafMax/2.0)-deltaY
     else:
         seedZ=self.motherPlant.heightStem+(self.motherPlant.heightLeafMax/2.0)
     self.z= seedZ
     self.r= self.radiusSeed
Example #2
0
 def checkDistanceMortality(self):
     if self.allowDistanceFromMother and self.janzenConnell > 0.0:
         theGarden = self
         if theGarden.showProgressBar:
             print "***Checking for mortality due to proximity to mother...***"
             theProgressBar = progressBarClass.progressbarClass(
                 len(theGarden.soil), "*")
         #print "Name : Distance : Chance"
         for obj in theGarden.soil[:]:
             if not obj.isSeed:
                 twoPi = 2.0 * 3.14
                 stddev = self.janzenConnell
                 theAvg = 0.0
                 theDistance = geometry_utils.distBetweenPoints(
                     obj.motherPlant.x, obj.motherPlant.y, obj.x, obj.y)
                 if theDistance > 0.0:
                     theExponent = -(((theDistance - theAvg)**2.0) /
                                     ((2.0 * stddev)**2.0))
                     theDeathChance = ((1 / (stddev * (twoPi**0.5))) *
                                       2.71)**theExponent
                     #print "%s : %s :%s" % (obj.name, theDistance, theDeathChance)
                     tooBad = random.random()
                     if tooBad < theDeathChance:
                         obj.causeOfDeath = "experimental death due to distance from mother"
                         theGarden.kill(obj)
             if theGarden.showProgressBar:
                 i = i + 1
                 theProgressBar.update(i)
Example #3
0
    def makeSeed(self, theSeed):
        theSeed = copy.deepcopy(self)
        theSeed.zeroSeedValues()
        theNameList = theSeed.name.split()
        #if len(theNameList)<2:
        #    idNumb=str(random.random())
        #else:
        #    idNumb=theNameList[1]
        theMax = self.locSeedFormation[0]
        theMin = self.locSeedFormation[1]
        ###Check these values and fix them if they have weird values
        if theMax > 1.0: self.locSeedFormation[0] = 1.0
        if theMax < 0.0: self.locSeedFormation[0] = 0.0
        if theMin > 1.0: self.locSeedFormation[1] = 1.0
        if theMin < 0.0: self.locSeedFormation[1] = 0.0
        ###
        theRadius = self.radiusLeaf
        r = theRadius * theMax
        delta = theRadius * theMin
        r = (random.random() * (r - delta)) + delta
        twoPi = 3.14 * 2
        theAngle = (random.random() * (twoPi - 0) + 0)
        seedX = r * math.cos(theAngle)
        seedY = r * math.sin(theAngle)
        theSeed.x = seedX + self.x
        theSeed.y = seedY + self.y
        if self.leafIsHemisphere:
            dist = geometry_utils.distBetweenPoints(seedX + self.x,
                                                    seedY + self.y, self.x,
                                                    self.y)
            if dist == self.radiusLeaf:
                deltaY = self.radiusLeaf
            elif dist == 0.0:
                deltaY = 0.0
            else:
                #deltaY=self.radiusLeaf-math.sqrt(abs((self.radiusLeaf*self.radiusLeaf)-(dist*dist)))
                deltaY = self.radiusLeaf - (
                    (abs((self.radiusLeaf * self.radiusLeaf) -
                         (dist * dist)))**0.5)
            seedZ = self.heightStem + (self.heightLeafMax / 2.0) - deltaY
        else:
            seedZ = self.heightStem + (self.heightLeafMax / 2.0)

        #theSeed.name="growingSeed %s" % (idNumb)
        theSeed.name = str(uuid.uuid4())
        theSeed.timeCreation = time.time()
        theSeed.motherPlant = self
        theSeed.motherPlantName = self.name
        theSeed.x = seedX + self.x
        theSeed.y = seedY + self.y
        theSeed.z = seedZ
        theSeed.r = theSeed.radiusSeed
        self.seedList.append(theSeed)
Example #4
0
 def makeSeed(self, theSeed):
     theSeed=copy.deepcopy(self)
     theSeed.zeroSeedValues()
     theNameList= theSeed.name.split()
     #if len(theNameList)<2:
     #    idNumb=str(random.random())
     #else:
     #    idNumb=theNameList[1]
     theMax=self.locSeedFormation[0]
     theMin=self.locSeedFormation[1]
     ###Check these values and fix them if they have weird values
     if theMax>1.0: self.locSeedFormation[0]=1.0
     if theMax<0.0: self.locSeedFormation[0]=0.0
     if theMin>1.0: self.locSeedFormation[1]=1.0
     if theMin<0.0: self.locSeedFormation[1]=0.0
     ###
     theRadius=self.radiusLeaf
     r=theRadius*theMax
     delta=theRadius*theMin
     r=(random.random()*(r-delta))+ delta
     twoPi=3.14*2
     theAngle=(random.random()*(twoPi-0)+0)
     seedX=r*math.cos(theAngle)
     seedY=r*math.sin(theAngle)
     theSeed.x= seedX +self.x
     theSeed.y= seedY +self.y
     if self.leafIsHemisphere:
         dist=geometry_utils.distBetweenPoints(seedX+self.x, seedY+self.y, self.x, self.y)
         if dist==self.radiusLeaf:
             deltaY=self.radiusLeaf
         elif dist==0.0:
             deltaY=0.0
         else:
             #deltaY=self.radiusLeaf-math.sqrt(abs((self.radiusLeaf*self.radiusLeaf)-(dist*dist)))
             deltaY=self.radiusLeaf-((abs((self.radiusLeaf*self.radiusLeaf)-(dist*dist)))**0.5)
         seedZ=self.heightStem+(self.heightLeafMax/2.0)-deltaY
     else:
         seedZ=self.heightStem+(self.heightLeafMax/2.0)
     
     #theSeed.name="growingSeed %s" % (idNumb)
     theSeed.name=str(uuid.uuid4())
     theSeed.timeCreation=time.time()
     theSeed.motherPlant=self
     theSeed.motherPlantName=self.name
     theSeed.x= seedX +self.x
     theSeed.y= seedY +self.y
     theSeed.z= seedZ
     theSeed.r= theSeed.radiusSeed
     self.seedList.append(theSeed)
Example #5
0
    def growSeedOnPlant(self, maxCarbonForSeed):
        if maxCarbonForSeed > self.motherPlant.massSeedMax:
            maxCarbonForSeed = self.motherPlant.massSeedMax
        if not self.motherPlant.massFixed == -0.0:
            if maxCarbonForSeed > self.motherPlant.massFixed:
                maxCarbonForSeed = self.motherPlant.massFixed
        self.motherPlant.massFixed = self.motherPlant.massFixed - maxCarbonForSeed
        self.massSeed = self.massSeed + maxCarbonForSeed
        #use that value to calculate the radius of the seed
        #convert mass to volume and the get the radius
        i = self.massSeed / self.densitySeed  #this is volume in m^3
        #i=i/(4.0/3.0)
        i = i / 1.3333
        #i=i/(math.pi)
        i = i / 3.14
        #i=math.pow(i, 1.0/3.0)
        #i=math.pow(i, 0.3333)
        i = i**0.3333
        self.radiusSeed = i

        ###need to move the seed as the plant grows###
        if self.motherPlant.leafIsHemisphere:
            dist = geometry_utils.distBetweenPoints(self.x, self.y,
                                                    self.motherPlant.x,
                                                    self.motherPlant.y)
            if dist == self.motherPlant.radiusLeaf:
                deltaY = self.motherPlant.radiusLeaf
            elif dist == 0.0:
                deltaY = 0.0
            else:
                deltaY = self.motherPlant.radiusLeaf - (
                    (abs((self.motherPlant.radiusLeaf *
                          self.motherPlant.radiusLeaf) - (dist * dist)))**0.5)
            seedZ = self.motherPlant.heightStem + (
                self.motherPlant.heightLeafMax / 2.0) - deltaY
        else:
            seedZ = self.motherPlant.heightStem + (
                self.motherPlant.heightLeafMax / 2.0)
        self.z = seedZ
        self.r = self.radiusSeed
Example #6
0
	def checkDistanceMortality(self):
		if self.allowDistanceFromMother:
			theGarden=self
			if theGarden.showProgressBar:
				print "***Checking for mortality due to proximity to mother...***"
				theProgressBar= progressBarClass.progressbarClass(len(theGarden.soil),"*")
			#print "Name : Distance : Chance"
			for obj in theGarden.soil[:]:
				if not obj.isSeed:
					twoPi=2.0*3.14
					stddev=0.9
					theAvg=0.0
					theDistance=geometry_utils.distBetweenPoints(obj.motherPlant.x, obj.motherPlant.y, obj.x, obj.y)
					if theDistance>0.0:
						theExponent=-(((theDistance-theAvg)**2.0)/((2.0*stddev)**2.0))
						theDeathChance=((1/(stddev*(twoPi**0.5)))*2.71)**theExponent
						#print "%s : %s :%s" % (obj.name, theDistance, theDeathChance)
						tooBad=random.random()
						if tooBad<theDeathChance:
							obj.causeOfDeath="experimental death due to distance from mother"
							theGarden.kill(obj)
				if theGarden.showProgressBar:
					i=i+1
					theProgressBar.update(i)
Example #7
0
    def disperseSeed(self, theSeed, motherPlant, theGarden):
        ###this dispersal method needs to be better
        if motherPlant.seedDispersalMethod[0] == 0:
            ###This is just random anywhere in world###
            newX = random.randrange(
                -(theGarden.theWorldSize / 2),
                (theGarden.theWorldSize / 2)) + random.random()
            newY = random.randrange(
                -(theGarden.theWorldSize / 2),
                (theGarden.theWorldSize / 2)) + random.random()
        elif motherPlant.seedDispersalMethod[0] == 1:
            ###just drop the seed straight down###
            newX = theSeed.x
            newY = theSeed.y
        elif motherPlant.seedDispersalMethod[0] == 2:
            ###drop the seed in a circle with a defined max radius###
            theRadius = motherPlant.seedDispersalMethod[1]
            theMax = 1
            theMin = 0
            r = theRadius * theMax
            delta = theRadius * theMin
            r = (random.random() * (r - delta)) + delta
            #twoPi=math.pi*2
            twoPi = 3.14 * 2
            theAngle = (random.random() * (twoPi - 0) + 0)
            newX = r * math.cos(theAngle)
            newY = r * math.sin(theAngle)
            newX = newX + theSeed.x
            newY = newY + theSeed.y
        elif motherPlant.seedDispersalMethod[0] == 3:
            ###eject the seed straight out from leaf, traveling a defined max distance###
            maxDistance = motherPlant.seedDispersalMethod[1]
            theMax = 1
            theMin = 0
            theDistance = maxDistance * theMax
            delta = maxDistance * theMin
            theDistance = (random.random() * (theDistance - delta)) + delta
            theHypot = geometry_utils.distBetweenPoints(
                motherPlant.x, motherPlant.y, theSeed.x, theSeed.y)
            theRise = theSeed.y - motherPlant.y
            theRun = theSeed.x - motherPlant.x
            theAngle = math.asin(theRise / theHypot)
            #theAngle=math.degrees(theAngle)
            newX = math.cos(theAngle) * theDistance
            if theRun < 0.0:
                newX = 0.0 - newX
            newY = math.sin(theAngle) * theDistance
            newX = newX + theSeed.x
            newY = newY + theSeed.y
        elif motherPlant.seedDispersalMethod[0] == 4:
            ###get a random angle based on input###
            angle = motherPlant.seedDispersalMethod[1]
            theVariance = (random.random() * ((angle * 0.5) - 0.0)) + 0.0
            if random.random() > 0.5:
                theVariance = 0 - theVariance
            angle = angle + theVariance
            angle = math.radians(angle)

            ###get a random velocity based on input###
            ####it would be nicer to use a force so seed size influences things too
            v = motherPlant.seedDispersalMethod[2]
            theVariance = (random.random() * ((v * 0.5) - 0.0)) + 0.0
            if random.random() > 0.5:
                theVariance = 0 - theVariance
            v = v + theVariance

            g = theGarden.gravity
            h = motherPlant.heightStem + motherPlant.heightLeafMax

            tempVar1 = (v * math.cos(angle)) / g
            tempVar2 = (v * math.sin(angle))
            #tempVar3= math.sqrt((tempVar2*tempVar2)+(2*g*h))
            tempVar3 = ((tempVar2 * tempVar2) + (2 * g * h))**0.5
            tempVar3 = tempVar2 + tempVar3
            theDistance = tempVar1 * tempVar3
            theHypot = geometry_utils.distBetweenPoints(
                motherPlant.x, motherPlant.y, theSeed.x, theSeed.y)
            theRise = theSeed.y - motherPlant.y
            theRun = theSeed.x - motherPlant.x
            theAngle = math.asin(theRise / theHypot)
            newX = math.cos(theAngle) * theDistance
            if theRun < 0.0:
                newX = 0.0 - newX
            newY = math.sin(theAngle) * theDistance
            newX = newX + theSeed.x
            newY = newY + theSeed.y

        #print "********seed %s be being placed at %f, %f" % (theSeed.name, newX, newY)
        theSeed.x = newX
        theSeed.y = newY
        theSeed.countToGerm = self.delayInGermination
        theGarden.plantSeed(theSeed)
        motherPlant.seedList.remove(theSeed)
Example #8
0
 def disperseSeed(self, theSeed, motherPlant, theGarden):
     ###this dispersal method needs to be better
     if motherPlant.seedDispersalMethod[0]==0:
         ###This is just random anywhere in world###
         newX =random.randrange(-(theGarden.theWorldSize/2),(theGarden.theWorldSize/2))+random.random()
         newY =random.randrange(-(theGarden.theWorldSize/2),(theGarden.theWorldSize/2))+random.random()
     elif motherPlant.seedDispersalMethod[0]==1:
         ###just drop the seed straight down###
         newX=theSeed.x
         newY=theSeed.y
     elif motherPlant.seedDispersalMethod[0]==2:
         ###drop the seed in a circle with a defined max radius###
         theRadius=motherPlant.seedDispersalMethod[1]
         theMax=1
         theMin=0
         r=theRadius*theMax
         delta=theRadius*theMin
         r=(random.random()*(r-delta))+ delta
         #twoPi=math.pi*2
         twoPi=3.14*2
         theAngle=(random.random()*(twoPi-0)+0)
         newX =r*math.cos(theAngle)
         newY =r*math.sin(theAngle)
         newX = newX + theSeed.x
         newY = newY + theSeed.y
     elif motherPlant.seedDispersalMethod[0]==3:
         ###eject the seed straight out from leaf, traveling a defined max distance###
         maxDistance=motherPlant.seedDispersalMethod[1]
         theMax=1
         theMin=0
         theDistance= maxDistance*theMax
         delta= maxDistance*theMin
         theDistance =(random.random()*(theDistance-delta))+ delta
         theHypot=geometry_utils.distBetweenPoints(motherPlant.x, motherPlant.y, theSeed.x, theSeed.y)
         theRise=theSeed.y-motherPlant.y
         theRun=theSeed.x-motherPlant.x
         theAngle=math.asin(theRise/theHypot)
         #theAngle=math.degrees(theAngle)
         newX=math.cos(theAngle)*theDistance
         if theRun<0.0:
             newX=0.0-newX
         newY=math.sin(theAngle)*theDistance
         newX=newX+theSeed.x
         newY=newY+theSeed.y
     elif motherPlant.seedDispersalMethod[0]==4:
         ###get a random angle based on input###
         angle=motherPlant.seedDispersalMethod[1]
         theVariance=(random.random()*((angle*0.5)-0.0))+ 0.0
         if random.random()>0.5:
             theVariance=0-theVariance
         angle=angle+theVariance
         angle=math.radians(angle)
         
         ###get a random velocity based on input###
         ####it would be nicer to use a force so seed size influences things too
         v=motherPlant.seedDispersalMethod[2]
         theVariance=(random.random()*((v*0.5)-0.0))+ 0.0
         if random.random()>0.5:
             theVariance=0-theVariance
         v=v+theVariance
         
         g=theGarden.gravity
         h=motherPlant.heightStem+motherPlant.heightLeafMax
         
         tempVar1= (v*math.cos(angle))/g
         tempVar2= (v*math.sin(angle))
         #tempVar3= math.sqrt((tempVar2*tempVar2)+(2*g*h))
         tempVar3= ((tempVar2*tempVar2)+(2*g*h))**0.5
         tempVar3= tempVar2+tempVar3
         theDistance=tempVar1*tempVar3
         theHypot=geometry_utils.distBetweenPoints(motherPlant.x, motherPlant.y, theSeed.x, theSeed.y)
         theRise=theSeed.y-motherPlant.y
         theRun=theSeed.x-motherPlant.x
         theAngle=math.asin(theRise/theHypot)
         newX=math.cos(theAngle)*theDistance
         if theRun<0.0:
             newX=0.0-newX
         newY=math.sin(theAngle)*theDistance
         newX=newX+theSeed.x
         newY=newY+theSeed.y
     
     
     #print "********seed %s be being placed at %f, %f" % (theSeed.name, newX, newY)
     theSeed.x=newX
     theSeed.y=newY
     theSeed.countToGerm=self.delayInGermination
     theGarden.plantSeed(theSeed)
     motherPlant.seedList.remove(theSeed)