Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.85 KB | None | 0 0
  1. import time
  2. import random
  3. import trick
  4.  
  5. class flower:
  6.     population = 0
  7.     def __init__(self, health = 100, dying = False, sunlightstorage = 0, waterstorage = 0, co2storage = 0, sugar = 600, age = 0, rootsize = 0, leafsize = 0, plantsize = 0, seeds = 0, phase = "sapling"):
  8.         self.health = health
  9.         self.dying = dying
  10.         self.sunlightstorage = sunlightstorage
  11.         self.waterstorage = waterstorage
  12.         self.co2storage = co2storage
  13.         self.sugar = sugar
  14.         self.age = age
  15.         self.rootsize = rootsize
  16.         self.leafsize = leafsize
  17.         self.plantsize = plantsize
  18.         self.seeds = seeds
  19.         self.phase = phase
  20.         flower.population = flower.population + 1
  21.     def sunlightabsorb(self, sunlight): #Takes in X units of sunlight, and stores them. X aught to be leafsize.
  22.         self.sunlightstorage = self.sunlightstorage + sunlight
  23.         if self.sunlightstorage > (self.plantsize * 10):
  24.             self.sunlightstorage = (self.plantsize * 10)
  25.         print "sunlight absorbed", self.sunlightstorage
  26.     def waterabsorption(self, water): #Takes in X units of water, and stores them. X aught to be rootsize.
  27.         self.waterstorage = self.waterstorage + water
  28.         if self.waterstorage > (self.plantsize * 10):
  29.             self.waterstorage = (self.plantsize * 10)
  30.         print "water absorbed", self.waterstorage
  31.     def co2absorption(self, co2): #Takes in X untis of Co2 and stores them, X aught to be leafsize.
  32.         self.co2storage = self.co2storage + co2
  33.         if self.co2storage > (self.plantsize * 10):
  34.             self.co2storage = (self.plantsize * 10)
  35.         print "co2 absorbed", self.co2storage
  36.     def photosynthesis(self):
  37.         if self.co2storage > 10 and self.waterstorage > 10 and self.sunlightstorage > 10:
  38.             self.co2storage = self.co2storage - 10
  39.             self.waterstorage = self.waterstorage - 10
  40.             self.sunlightstorage = self.sunlightstorage - 10
  41.             self.sugar = self.sugar + 10
  42.             print "sugar get"
  43.     def regeneration(self):
  44.         if self.sugar > 4:
  45.             self.sugar = self.sugar - (self.plantsize + self.rootsize + self.leafsize)
  46.         else:
  47.             grower = trick.pullrandom(("Roots", "leaves", "size"))
  48.             if grower == "Roots":
  49.                 self.rootsize = self.rootsize - 1
  50.                 if self.rootsize < 0:
  51.                     self.rootsize = 0
  52.             elif grower == "leaves":
  53.                 self.leafsize = self.leafsize - 1
  54.                 if self.leafsize < 0:
  55.                     self.leafsize = 0
  56.             elif grower == "size":
  57.                 self.plantsize = self.plantsize - 1
  58.                 if self.plantsize < 0:
  59.                     self.plantsize = 0
  60.         if self.sugar > 4:
  61.             grower = trick.pullrandom(("Roots", "leaves", "size"))
  62.             if grower == "Roots":
  63.                 self.rootsize = self.rootsize + 1
  64.             elif grower == "leaves":
  65.                 self.leafsize = self.leafsize + 1
  66.             elif grower == "size":
  67.                 self.plantsize = self.plantsize + 1
  68.         print "roots -", self.rootsize, "leaves -", self.leafsize, "plant -", self.plantsize
  69.     def aging(self):
  70.         self.age = self.age + 1
  71.         if self.age == 1640:
  72.             self.phase = "plant"
  73.         if self.age == 13940:
  74.             self.phase = "flower"
  75.     def pollination(self, wind):
  76.         if self.seeds > 0 and self.phase == "flower":
  77.             self.seeds = self.seeds - wind
  78.             for i in range(1, wind):
  79.                 randomnumber = randit(1, 30)
  80.                 if randomnumber == 1:
  81.                     pass #initialize new flower
  82.     def death(self):
  83.         if self.plantsize == 0 and self.rootsize == 0 and self.leafsize == 0:
  84.             pass #death
  85.         if age == 24600:
  86.             pass #death
  87.     def __del__(self):
  88.         flower.population = flower.population - 1
  89.        
  90. co2 = 500
  91. water = 500
  92. sunlight = 500
  93. wind = 1
  94.  
  95. f = flower()
  96. while True:
  97.     time.sleep(1)
  98.     f.aging()
  99.     f.regeneration()
  100.     if co2 >= f.leafsize and (f.leafsize + f.co2storage) < (f.plantsize * 10):
  101.         f.co2absorption(f.leafsize)
  102.         co2 = co2 - f.leafsize
  103.     if sunlight >= f.leafsize and (f.leafsize + f.sunlightstorage) < (f.plantsize *10):
  104.         f.sunlightabsorb(f.leafsize)
  105.     if water >= f.rootsize and (f.rootsize + f.waterstorage) < (f.plantsize * 10):
  106.         f.waterabsorption(f.rootsize)
  107.         water = water - f.rootsize
  108.     f.photosynthesis()
  109.     f.pollination(wind)
  110.     print f.age
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement