Advertisement
Chl_Snt

Untitled

Mar 30th, 2025
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. def horse_stat_modifier(age, start_age=5, max_age=30, plateau_width=0.33):
  5.     mid_age = (max_age + start_age) / 2  # Средний возраст (15 лет)
  6.     plateau_start = mid_age - (mid_age - start_age) * plateau_width
  7.     plateau_end = mid_age + (max_age - mid_age) * plateau_width
  8.  
  9.     if age < start_age or age > max_age:
  10.         return 0  # За границами возрастов коэффициент 0
  11.  
  12.     if start_age <= age < plateau_start:
  13.         return (age - start_age) / (plateau_start - start_age)  # Рост
  14.     elif plateau_start <= age <= plateau_end:
  15.         return 1  # Плато, статы не меняются
  16.     else:
  17.         return (max_age - age) / (max_age - plateau_end)  # Убывание
  18.  
  19. # Создаем массив возрастов от 0 до 33 лет с шагом 0.1
  20. ages = np.arange(0, 33, 0.1)
  21. modifiers = []
  22.  
  23. # Вывод в консоль
  24. print("Возраст | Коэффициент")
  25. print("-" * 25)
  26. for age in ages:
  27.     modifier = horse_stat_modifier(age)
  28.     modifiers.append(modifier)
  29.     print(f"{age:6.1f}  | {modifier:.3f}")
  30.  
  31. # Построение графика
  32. plt.figure(figsize=(10, 5))
  33. plt.plot(ages, modifiers, label="Коэффициент статов", color="blue", linewidth=2)
  34. plt.axvline(x=3, color="gray", linestyle="--", label="Стартовый возраст")
  35. plt.axvline(x=30, color="gray", linestyle="--", label="Максимальный возраст")
  36. plt.axhline(y=1, color="red", linestyle="--", label="Макс. уровень статов (плато)")
  37.  
  38. plt.xlabel("Возраст лошади (лет)")
  39. plt.ylabel("Коэффициент")
  40. plt.title("Изменение коэффициента статов лошади с возрастом")
  41. plt.legend()
  42. plt.grid(True)
  43. plt.show()
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement