Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- diamondDurability = 1562
- def checkBreak (level):
- formula = int((100 / (level + 1)))
- roll = random.randint(0, 100)
- if roll <= formula:
- # Lost Durability
- return True
- elif roll > formula:
- # Kept Durability
- return False
- pickaxes = int(input("How many pickaxes would you like to use? "))
- level = int(input("What level unbreaking do the pickaxes have? "))
- pickaxeLifeSpan = []
- lowestDurability = 10000000
- highestDurability = 0
- while pickaxes > 0:
- tests = 0
- durability = diamondDurability
- while durability > 0:
- if checkBreak(level):
- durability -= 1
- tests += 1
- pickaxeLifeSpan.append(tests)
- print("Pickaxe broke after", tests, "blocks broken.")
- if tests > highestDurability:
- highestDurability = tests
- if tests < lowestDurability:
- lowestDurability = tests
- pickaxes -= 1
- print("The average number of blocks broken needed to break a pickaxe is", (sum(pickaxeLifeSpan) // len(pickaxeLifeSpan)))
- print("The least lasting pickaxe lasted", lowestDurability, "blocks broken.")
- print("The longest lasting pickaxe lasted", highestDurability, "blocks broken.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement