Untitled
unknown
python
a year ago
3.5 kB
3
Indexable
import random def calculate_tap_cost(equip_level, current_star, safeguard=False, fifteen_free=False, thirty_percent_off=False): base_cost = 100 * \ round((equip_level ** 3 * (current_star + 1) ** 2.7 / 20000) + 10) if safeguard and not fifteen_free and (current_star == 15 or current_star == 16): return base_cost * 2 if thirty_percent_off: base_cost *= 0.7 return int(base_cost) def starforce_simulation(starting_stars, max_stars, safeguard=False, fifteen_free=False, thirty_percent_off=False): cost_so_far = 0 stars = starting_stars equip_level = 250 while stars < max_stars: success_rate, fail_maintain_rate, fail_decrease_rate, boom_rate = get_rates( stars, safeguard) if fifteen_free and stars == 15: success_rate = 1.0 # 100% success rate for 15->16 result = random.choices(['success', 'fail_maintain', 'fail_decrease', 'boom'], weights=[success_rate, fail_maintain_rate, fail_decrease_rate, boom_rate], k=1)[0] cost_so_far += calculate_tap_cost(equip_level, stars, safeguard, fifteen_free, thirty_percent_off) if result == 'success': stars += 1 elif result == 'fail_maintain': pass elif result == 'fail_decrease': if stars != 15 and stars != 20: stars -= 1 else: return 'boom', cost_so_far return stars, cost_so_far def get_rates(stars, safeguard=False): if safeguard and stars == 15: return 0.30, 0.0, 0.0, 0.0 elif safeguard and stars == 16: return 0.30, 0.0, 0.672, 0.0 elif stars == 15: return 0.30, 0.0, 0.672, 0.028 elif stars == 16 or stars == 17: return 0.30, 0.0, 0.679, 0.021 elif stars == 18 or stars == 19: return 0.30, 0.0, 0.672, 0.028 elif stars == 20 or stars == 21: return 0.30, 0.63, 0.0, 0.07 num_simulations = 10000 total_cost = 0 for _ in range(num_simulations): _, cost = starforce_simulation( 15, 22, safeguard=False, fifteen_free=False, thirty_percent_off=False) total_cost += cost average_cost = total_cost / num_simulations print("Average cost without safeguard, no 5/10/15, without 30 %:", "{:,.2f}B".format(average_cost / 1000000000)) total_cost = 0 for _ in range(num_simulations): _, cost = starforce_simulation( 15, 22, safeguard=False, fifteen_free=True, thirty_percent_off=True) total_cost += cost average_cost = total_cost / num_simulations print("Average cost without safeguard, 5/10/15, 30%:", "{:,.2f}B".format(average_cost / 1000000000)) total_cost = 0 for _ in range(num_simulations): _, cost = starforce_simulation( 15, 22, safeguard=True, fifteen_free=True, thirty_percent_off=False) total_cost += cost average_cost = total_cost / num_simulations print("Average cost with safeguard, 5/10/15, without 30% :", "{:,.2f}B".format(average_cost / 1000000000)) total_cost = 0 for _ in range(num_simulations): _, cost = starforce_simulation( 15, 22, safeguard=True, fifteen_free=True, thirty_percent_off=True) total_cost += cost average_cost = total_cost / num_simulations print("Average cost with safeguard, 5/10/15, 30%:", "{:,.2f}B".format(average_cost / 1000000000))
Editor is loading...
Leave a Comment