Guest User

Python code

a guest
Nov 10th, 2018
3,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.95 KB | None | 0 0
  1. #Import modules
  2. import random
  3.  
  4. #Define species, causes of death, and genders
  5. different_species = ["ant", "ape", "bear", "cat", "dog", "wolf"]
  6.  
  7. ant_deaths = ["you got crushed.", "you carried a little more than 50\ntimes your own weight.", "you forgot your way to the hill.", "you recieved the death sentence from\nthe queen ant."]
  8.  
  9. ape_deaths = ["you climbed too high.", "you failed to find your daily banana."]
  10.  
  11. bear_deaths = ["the fishermen took all the fish.", "you hibernated too long!"]
  12.  
  13. cat_deaths = ["you didn't use the scratching pole\nfor more than 5 minutes.", "your owner got a dog.", "starvation."]
  14.  
  15. dog_deaths = ["you ran too fast.", "you returned to the wild to\nfind your ancestors. Little did you know the wild doesn't\nhave belly rubs!", "starvation"]
  16.  
  17. wolf_deaths = ["you got outplayed", "you tripped and fell down a steep\nflight of stairs, crashing into a Ginsu knife\ndisplay at the bottom.", "you didn't find any food."]
  18.  
  19. genders = ["male", "female"]
  20.  
  21. #Define different species' habitats
  22. ant_habitats = ["desert", "grassland", "ant farm"]
  23.  
  24. ape_habitats = ["jungle", "savanna", "mountainous area"]
  25.  
  26. bear_habitats = ["forest", "tundra", "mountainous area"]
  27.  
  28. wolf_habitats = ["tundra", "forest", "mountainous area", "shrubland"]
  29.  
  30. #Define variables
  31. life_status = "alive"
  32. age = -1
  33. gender = random.choice(genders)
  34. species = random.choice(different_species)
  35. death_message = ""
  36.  
  37. #Define different scenarios
  38. ant_queen = False
  39. ant_worker = False
  40. ant_drone = False
  41. ant_defender = False
  42.  
  43. ape_leader = False
  44. ape_family = False
  45. ape_hungry = False
  46. ape_productive = False
  47.  
  48. bear_mom = False
  49. bear_hungry = False
  50.  
  51. cat_mom = False
  52. cat_dad = False
  53. cat_owner_left = False
  54.  
  55. dog_mom = False
  56. dog_dad = False
  57. dog_owner_left = False
  58.  
  59. wolf_alpha = False
  60. wolf_mom = False
  61. wolf_dad = False
  62. wolf_hungry = False
  63. wolf_productive = False
  64.  
  65. #Define high and low chances of events happening
  66. low_chance = 1
  67. high_chance = 75
  68.  
  69. #Define functions
  70. def decide_home():
  71.     if species == "ant":
  72.         home = random.choice(ant_habitats)
  73.         return home
  74.    
  75.     elif species == "ape":
  76.         home = random.choice(ape_habitats)
  77.         return home
  78.        
  79.     elif species == "bear":
  80.         home = random.choice(bear_habitats)
  81.         return home
  82.    
  83.     elif species == "cat" or species == "dog":
  84.         home = "human's house"
  85.         return home
  86.    
  87.     elif species == "wolf":
  88.         home = random.choice(wolf_habitats)
  89.         return home
  90.  
  91. def start_life():
  92.     home = decide_home()
  93.     male_random_message = chance_dice(0, 1)
  94.     female_random_message = chance_dice(0, 1)
  95.     if gender == "male":
  96.         if male_random_message == 0:
  97.             print("You are born into this world with the two\nchromosomes:")
  98.             print("XY")
  99.             print("Thus, you become a male " + species + ".")
  100.             print("You live in a " + home + ".")
  101.        
  102.         elif male_random_message == 1:
  103.             print("Nice! A computer algorithm chose you to become\na male " + species + "!")
  104.             print("You live in a " + home + ".")
  105.    
  106.     elif gender == "female":
  107.         if female_random_message == 0:
  108.             print("You are born into this world with the two\nchromosomes:")
  109.             print("XX")
  110.             print("Thus, you become a female " + species + ".")
  111.             print("You live in a " + home + ".")
  112.        
  113.         elif female_random_message == 1:
  114.             print("Awesome! A cool computer algorithm chose you to\nbecome a female " + species + "!")
  115.             print("You live in a " + home + ".")
  116.  
  117. def determine_death():
  118.     if species == "ant" and ant_queen == True:
  119.         death_message = random.choice(ant_deaths[0:4])
  120.    
  121.     elif species == "ant" and ant_queen == False:
  122.         death_message = random.choice(ant_deaths)
  123.    
  124.     elif species == "ape":
  125.         death_message = random.choice(ape_deaths)
  126.    
  127.     elif species == "bear" and bear_hungry == True:
  128.         death_message = bear_deaths[0]
  129.    
  130.     elif species == "bear" and bear_hungry == False:
  131.         death_message = bear_deaths[1]
  132.        
  133.     elif species == "cat" and cat_owner_left == True:
  134.         death_message = cat_deaths[2]
  135.        
  136.     elif species == "cat" and cat_owner_left == False:
  137.         death_message = random.choice(cat_deaths[0:3])
  138.    
  139.     elif species == "dog" and dog_owner_left == True:
  140.         death_message = dog_deaths[2]
  141.    
  142.     elif species == "dog" and dog_owner_left == False:
  143.         death_message = random.choice(dog_deaths[0:3])
  144.    
  145.     elif species == "wolf" and wolf_hungry == True:
  146.         death_message = wolf_deaths[2]
  147.    
  148.     elif species == "wolf" and wolf_hungry == False:
  149.         death_message = random.choice(wolf_deaths[0:3])
  150.    
  151.     elif species == "ant" and ant_queen == True and age >= 25:
  152.         death_message = "natural causes."
  153.    
  154.     elif species == "ant" and ant_queen == False and age >= 3:
  155.         death_message = "natural causes."
  156.    
  157.     elif species == "ape" and age >= 25:
  158.         death_message = "natural causes."
  159.    
  160.     elif species == "bear" and age >= 33:
  161.         death_message = "natural causes."
  162.    
  163.     elif species == "dog" and age >= 9:
  164.         death_message = "natural causes."
  165.    
  166.     elif species == "cat" and age >= 11:
  167.         death_message = "natural causes."
  168.    
  169.     elif species == "wolf" and age >= 9:
  170.         death_message = "natural causes."
  171.        
  172.     return death_message
  173.  
  174. def death_note():
  175.     print("\n======== R.I.P ========")
  176.     print("You have just passed away.\nCause of death: " + determine_death())
  177.     print("Click 'RUN' for a new life!")
  178.    
  179.     if determine_death == "natural causes.":
  180.         natural_death_note()
  181.  
  182. def natural_death_note():
  183.     if determine_death() == "natural causes.":
  184.         print("\n======== R.I.P ========")
  185.         print("You have just passed away of natural causes.")
  186.         print("Click 'RUN' for a new life!")
  187.    
  188.     elif determine_death() == "natural causes." and ant_queen == True:
  189.         print("\n~~~~~~~~ R.I.P ~~~~~~~")
  190.         print("The queen ant has just passed away of natural causes.")
  191.         print("Click 'RUN' for a new life!")
  192.    
  193.     elif determine_death() == "natural causes." and ape_leader == True:
  194.         print("\n~~~~~~~~ R.I.P ~~~~~~~")
  195.         print("The leader of the apes has just passed\naway of natural causes.")
  196.         print("Click 'RUN' for a new life!")
  197.    
  198.     elif determine_death() == "natural causes." and wolf_alpha == True:
  199.         print("\n~~~~~~~~ R.I.P ~~~~~~~")
  200.         print("The alpha wolf has just passed away of natural causes.")
  201.         print("Click 'RUN' for a new life!")
  202.  
  203. def chance_dice(a,b):
  204.     return int(random.randint(a,b))
  205.  
  206. #Show the instructions and set the scene
  207. old_age_death = chance_dice(0, 2)
  208.  
  209. print("Welcome to The Circle of Life, made by DrChicken24.")
  210. print("Press the 'RUN' button for a new life every time!")
  211. print("")
  212.  
  213. print("----------------------------------------------------\n") #Seperator
  214.  
  215. start_life()
  216. print("")
  217. print("And here goes your life as a " + species + ":")
  218. print("")
  219.  
  220. #Game logic
  221. while life_status == "alive":
  222.     age += 1
  223.     if age != 0:
  224.         print("Age: " + str(age))
  225.    
  226.     if random.randint(low_chance, high_chance) == 23:
  227.         life_status = "dead"
  228.    
  229.     #You get more likely to die the longer you live
  230.     #Ants
  231.     if species == "ant" and ant_queen == False and age <= 1:
  232.         high_chance = 25
  233.     elif species == "ant" and ant_queen == False and age <= 2:
  234.         high_chance = 24
  235.     elif species == "ant" and ant_queen == False and age >= 3:
  236.         low_chance = 22
  237.    
  238.     #Queen ant
  239.     if species == "ant" and ant_queen == True and age <= 3:
  240.         high_chance = 150
  241.     elif species == "ant" and ant_queen == True and age <= 10:
  242.         high_chance = 100
  243.     elif species == "ant" and ant_queen == True and age <= 14:
  244.         high_chance = 70
  245.     elif species == "ant" and ant_queen == True and age >= 20:
  246.         high_chance = 30
  247.     elif species == "ant" and ant_queen == True and age >= 30:
  248.         high_chance = 24
  249.    
  250.     #Apes
  251.     if species == "ape" and age <= 4:
  252.         high_chance = 150
  253.     elif species == "ape" and age <= 10:
  254.         high_chance = 100
  255.     elif species == "ape" and age <= 14:
  256.         high_chance = 70
  257.     elif species == "ape" and age >= 25:
  258.         high_chance = 50
  259.     elif species == "ape" and age >= 45:
  260.         high_chance = 30
  261.     elif species == "ape" and age >= 50:
  262.         high_chance = 24
  263.    
  264.     #Bears
  265.     if species == "bear" and age <= 4:
  266.         high_chance = 150
  267.     elif species == "bear" and age <= 10:
  268.         high_chance = 100
  269.     elif species == "bear" and age <= 14:
  270.         high_chance = 70
  271.     elif species == "bear" and age >= 20:
  272.         high_chance = 50
  273.     elif species == "bear" and age >= 30:
  274.         high_chance = 30
  275.     elif species == "bear" and age >= 35:
  276.         high_chance = 24
  277.    
  278.     #Cats
  279.     if species == "cat" and age <= 1:
  280.         high_chance = 150
  281.     elif species == "cat" and age <= 3:
  282.         high_chance = 100
  283.     elif species == "cat" and age <= 5:
  284.         high_chance = 70
  285.     elif species == "cat" and age >= 8:
  286.         high_chance = 50
  287.     elif species == "cat" and age >= 12:
  288.         high_chance = 30
  289.     elif species == "cat" and age >= 15:
  290.         high_chance = 24
  291.    
  292.     #Dogs and wolves
  293.     if species == "dog" or species == "wolf" and age <= 1:
  294.         high_chance = 150
  295.     elif species == "dog" or species == "wolf" and age <= 2:
  296.         high_chance = 100
  297.     elif species == "dog" or species == "wolf" and age <= 4:
  298.         high_chance = 70
  299.     elif species == "dog" or species == "wolf" and age >= 7:
  300.         high_chance = 50
  301.     elif species == "dog" or species == "wolf" and age >= 10:
  302.         high_chance = 30
  303.     elif species == "dog" or species == "wolf" and age >= 13:
  304.         high_chance = 24
  305.        
  306.     #Random events that happen during your life
  307.     #Queen ant
  308.     if species == "ant" and age == chance_dice(1, 200) and gender == "female" and ant_queen == False:
  309.         print("WOW! You got amazingly lucky and\nbecame the queen ant!")
  310.         ant_queen == True
  311.    
  312.     #Worker ant
  313.     if species == "ant" and gender == "female" and ant_worker == False:
  314.         print("Since you were born a female, you\nbecame a worker ant to help the colony\nand take care of the queen!")
  315.         ant_worker = True
  316.    
  317.     #Drone ant
  318.     if species == "ant" and gender == "male" and ant_drone == False:
  319.         print("You were born a male, so you\nare born into the drone position.\nYour job is to repopulate the\ncolony so it can live on!")
  320.         ant_drone = True
  321.    
  322.     #Defender ant
  323.     if species == "ant" and age == chance_dice(1, 10) and gender == "male" and ant_defender == False:
  324.         print("You were personally chosen by the queen\nto defend the colony and become a defender ant!")
  325.         ant_defender == True
  326.    
  327.     #Ape leader
  328.     if species == "ape" and age == chance_dice(20, 220) and ape_leader == False:
  329.         print("AMAZING! You recieved the title of\nleader within your troop!")
  330.         ape_leader == True
  331.    
  332.     #Ape family
  333.     if species == "ape" and age == chance_dice(20, 30) and ape_family == False:
  334.         print("You met another ape like\nyourself and had a family!")
  335.         ape_family == True
  336.    
  337.     #Ape hungry
  338.     if species == "ape" and age == chance_dice(1, 70) and ape_hungry == False:
  339.         print("A time of great famine has\nfallen upon your troop.")
  340.         ape_hungry == True
  341.    
  342.     #Ape productive
  343.     if species == "ape" and age == chance_dice(1, 50) and ape_productive == False:
  344.         print("It was a productive year!")
  345.         ape_productive == True
  346.    
  347.     #Bear mom
  348.     if species == "bear" and age == chance_dice(20, 30) and gender == "female" and bear_mom == False:
  349.         print("You became a mother to " + str(chance_dice(1, 3)) + " cubs!")
  350.         bear_mom = True
  351.    
  352.     #Bear hungry
  353.     if species == "bear" and age == chance_dice(1, 50) and ape_hungry == False:
  354.         print("A time of great famine has fallen upon you.")
  355.         bear_hungry == True
  356.    
  357.     #Cat mom
  358.     if species == "cat" and age == chance_dice(1, 5) and gender == "female" and cat_mom == False:
  359.         print("You found a mate and gave birth to " + str(chance_dice(1, 8)) + " kittens.")
  360.         cat_mom = True
  361.    
  362.     #Cat dad
  363.     if species == "cat" and age == chance_dice(1, 3) and gender == "male" and cat_dad == False:
  364.         print("You found a mate and became a father to " + str(chance_dice(1, 8)) + " kittens.")
  365.         cat_dad = True
  366.    
  367.     #Cat owner left
  368.     if species == "cat" and cat_owner_left == False:
  369.         print("A very unfortunate chain of events\nled to your owner abandoning you...")
  370.         cat_owner_left = True
  371.    
  372.     #Dog mom
  373.     if species == "dog" and age == chance_dice(1, 5) and gender == "female" and dog_mom == False:
  374.         print("You found a mate and gave birth to " + str(chance_dice(1, 15)) + " puppies.")
  375.         dog_mom = True
  376.    
  377.     #Dog dad
  378.     if species == "dog" and age == chance_dice(1, 3) and gender == "male" and dog_dad == False:
  379.         print("You found a mate and became a father to " + str(chance_dice(1, 15)) + " puppies.")
  380.         dog_dad = True
  381.    
  382.     #Dog owner left
  383.     if species == "dog" and dog_owner_left == False:
  384.         print("A very unfortunate chain of events\nled to your owner abandoning you...")
  385.         dog_owner_left = True
  386.    
  387.     #Wolf alpha
  388.     if species == "wolf" and age == chance_dice(5, 10) and wolf_alpha == False:
  389.         print("Nice! You were randomly selected by some\nvery intricate computer algorithm to be the\n(virtual) alpha of a (also virtual) wolf pack!\n(This post was brought to you by wol;f ganfg)")
  390.         wolf_alpha = True
  391.    
  392.     #Wolf dad
  393.     if species == "wolf" and age == chance_dice(2, 3) and gender == "male" and wolf_dad == False:
  394.         print("You found a mate and became a father to " + str(chance_dice(1, 7)) + " pups.")
  395.         wolf_dad = True
  396.    
  397.     #Wolf mom
  398.     if species == "wolf" and age == chance_dice(2, 3) and gender == "female" and wolf_mom == False:
  399.         print("You found a mate and gave birth to " + str(chance_dice(1, 7)) + " pups.")
  400.         wolf_mom = True
  401.    
  402.     #Wolf hungry
  403.     if species == "wolf" and age == chance_dice(1, 50) and wolf_hungry == False:
  404.         print("A time of great famine has fallen upon your pack.")
  405.         wolf_hungry == True
  406.    
  407.     #Wolf productive
  408.     if species == "wolf" and age == chance_dice(1, 50) and wolf_productive == False:
  409.         print("It was a productive year for your pack!")
  410.         wolf_productive == True
  411.    
  412.     #DIE DIE DIE
  413.     if life_status == "dead":
  414.         death_note()
  415.        
  416.     #Natural deaths
  417.     #Ants
  418.     if species == "ant" and age >= 5:
  419.         if old_age_death == 1:
  420.             life_status = "dead"
  421.             natural_death_note()
  422.    
  423.     #Queen ant
  424.     if species == "ant" and ant_queen == True and age >= 30:
  425.         if old_age_death == 1:
  426.             life_status = "dead"
  427.             natural_death_note()
  428.    
  429.     #Ape
  430.     if species == "ape" and age >= 50:
  431.         if old_age_death == 1:
  432.             life_status = "dead"
  433.             natural_death_note()
  434.    
  435.     #Bear
  436.     if species == "bear" and age >= 35:
  437.         if old_age_death == 1:
  438.             life_status = "dead"
  439.             natural_death_note()
  440.    
  441.     #Cats, dogs, and wolves
  442.     if species == "cat" or species == "dog" or species == "wolf" and age >= 13:
  443.         if old_age_death == 1:
  444.             life_status = "dead"
  445.             natural_death_note()
Advertisement
Add Comment
Please, Sign In to add comment