deep_expo_percentage.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """Calculate resources koef"""
  2. def nth_root(num, root):
  3. """Calculte nth root"""
  4. answer = num ** (1/root)
  5. return answer
  6. def calc_resource_factor(resource_limit, koef_factor):
  7. """Calculate resource factor based on limit"""
  8. return pow(resource_limit * koef_factor / 10, 0.8)
  9. def calc_required_limit(koef, koef_factor):
  10. """Calculate amount of deep exploration points"""
  11. return (10 * nth_root(koef, 0.8)) / koef_factor
  12. def calc_deep_exploration(resource_limit, percentage, koef_factor, max_limit):
  13. """Calculate deep expo for resource"""
  14. initial_resource_factor = calc_resource_factor(resource_limit, koef_factor)
  15. new_resource_factor = initial_resource_factor * (percentage / 100 + 1)
  16. new_limit = calc_required_limit(new_resource_factor, koef_factor)
  17. if new_limit > max_limit:
  18. new_limit = max_limit
  19. new_resource_factor = calc_resource_factor(new_limit, koef_factor)
  20. percentage = 100 / initial_resource_factor * new_resource_factor - 100
  21. print("{:5.2f} {:4.2f} {:4.2f} {:4.0f}".format(
  22. percentage,
  23. initial_resource_factor,
  24. new_resource_factor,
  25. new_limit - resource_limit
  26. ))
  27. if __name__ == "__main__":
  28. print("% old new deep")
  29. print('Noord-Nederland')
  30. calc_deep_exploration(379, 0, 0.4, 637)
  31. print('Oost-Nederland')
  32. calc_deep_exploration(359, 50, 0.4, 637)
  33. print('West-Nederland')
  34. calc_deep_exploration(372, 50, 0.4, 637)
  35. print('Zuid-Nederland')
  36. calc_deep_exploration(366, 50, 0.4, 637)
  37. print('Amsterdam')
  38. calc_deep_exploration(418, 45, 0.4, 637)