from random import randint
from math import floor, ceil
from datetime import datetime, timedelta
from time import strftime
def ride_calculation(ride):
trips = attractions['Rides'][ride][3] / attractions['Rides'][ride][1]
if type(trips) == type(0.0):
decimal_index = str(trips).find('.')
first_decimal_place = str(trips)[decimal_index + 1]
if int(first_decimal_place) >= 5:
trips = ceil(trips)
else:
trips = floor(trips)
else:
trips = floor(trips)
waittime = trips * attractions['Rides'][ride][2]
return waittime
def ride_distribution(ride, guests):
ride_guests = 0
if ride not in broken_rides:
if attractions['Rides'][ride][0] == 3:
ride_guests = randint(0, int(guests[0] / ride_type[0]))
if ride_guests > (150 * attractions['Rides'][ride][0]):
ride_guests = 150 * attractions['Rides'][ride][0]
else:
guests[0] -= ride_guests
attractions['Rides'][ride].append(ride_guests)
elif attractions['Rides'][ride][0] == 2:
ride_guests = randint(0, int(guests[1] / ride_type[1]))
if ride_guests > (150 * attractions['Rides'][ride][0]):
ride_guests = 150 * attractions['Rides'][ride][0]
else:
guests[1] -= ride_guests
attractions['Rides'][ride].append(ride_guests)
else:
ride_guests = randint(0, int(guests[2] / ride_type[2]))
if ride_guests > (150 * attractions['Rides'][ride][0]):
ride_guests = 150 * attractions['Rides'][ride][0]
else:
guests[2] -= ride_guests
attractions['Rides'][ride].append(ride_guests)
else:
attractions['Rides'][ride].append(0)
now = datetime.today()
time_back = timedelta(hours = 5)
now_fixed = now - time_back
now_fixed = datetime(year = 2022, month = 1, day = 8, hour = 12, minute = 30)
if 9 <= now_fixed.hour <= 21:
# Ride Example Data: 'ride': [relative popularity, number of spots, time it takes for ride to complete, guests on the ride (later appended), time taken for the ride (later appended)]
attractions = {
'Rides':
{
'Jimbo Jambo Jammer': [3, 24, 180],
'Coastal Rockr\'': [3, 16, 220],
'Aeroplane Flyer': [3, 18, 135],
'Sky Drop': [3, 24, 280],
'Heaven Swings': [3, 18, 125],
'Rattler': [3, 16, 145],
'Polar Bear Express': [3, 20, 180],
'Bank Heist': [3, 18, 200],
'IT Adventure': [3, 22, 300],
'Scrambler': [2, 24, 145],
'Tic Tac Tosse\'': [2, 16, 120],
'Falcon\'s Nest': [2, 20, 180],
'Piff the Magic Dragon\'s Coaster': [2, 16, 200],
'Slippery Rails': [2, 24, 150],
'Yam\'s Adventures': [2, 12, 165],
'Benji and Tortle\'s River Chase': [2, 14, 180],
'Ting Tang Tailor\'s Terrifying Targeted Tamperings': [2, 18, 300],
'Mediocre Coaster': [2, 8, 120],
'Scooby Doo\'s Ghost Hunting Adventures': [2, 2, 60],
'Pampered Parrot\'s Perilous Escapades': [2, 12, 120],
'Zombie Shootout': [1, 18, 125],
'School Bus Ride': [1, 20, 120],
'Coding Adventure': [1, 24, 340],
'Window Cleaner\'s Adventure': [1, 12, 120],
'George and Max\'s Adventure': [1, 12, 200],
'Animal Adventures': [1, 4, 90],
'Safari Driver': [1, 60, 600],
'Snoopy and the Red Baron': [1, 20, 90],
'MIT Graduate Virtual Reality': [1, 3, 90]
}
}
for ride in attractions['Rides']:
work_eff = randint(1, 10)
attractions['Rides'][ride][2] -= (work_eff * 6)
broken_rides = []
for ride in attractions['Rides']:
if randint(0, 101) <= 5:
broken_rides.append(ride)
else:
pass
# Starts at 9am ends at 9pm
# 9 ## 10 # 11 # 12 ## 1 ## 2 ## 3 ## 4 ## 5 ## 6 ## 7 ## 8 ## 9
time_weights = [0.5 , 0.7, 0.9, 1.0, 1.1, 1.2, 1.2, 1.2, 1.1, 1.0, 0.7, 0.5, 0.5]
weighted_time = time_weights[now_fixed.hour - 9]
# # S ## M ## T ## W ## T ## F ## S #
day_weights = [1.35, 0.5, 0.5, 0.5, 0.6, 0.9, 1.5]
weighted_day = day_weights[int(now_fixed.strftime('%w'))]
#
park_popularity = 10
base_guests = 5000
total_guests = floor(randint(0, base_guests * park_popularity) * weighted_time * weighted_day)
# [big ride guests, medium ride guests, small ride guests, off ride guests]
guest_distribution = [floor(total_guests * 0.5), floor(total_guests * 0.4), floor(total_guests * 0.1)]
ride_type = [0, 0, 0]
for ride in attractions['Rides']:
if attractions['Rides'][ride][0] == 3:
ride_type[0] += 1
elif attractions['Rides'][ride][0] == 2:
ride_type[1] += 1
else:
ride_type[2] += 1
for park_ride in attractions['Rides']:
ride_distribution(park_ride, guest_distribution)
for ride in attractions['Rides']:
wait_time = ride_calculation(ride)
attractions['Rides'][ride].append(wait_time)
cont = ''
selected_ride = ''
while selected_ride != 'exit':
selected_ride = input('Name of ride you want to check the wait time for or exit to exit: ')
if selected_ride == 'a':
break
if selected_ride == 'exit':
break
if selected_ride in broken_rides:
print('That ride is out of commission, sorry.\n')
continue
while selected_ride not in attractions['Rides'] or selected_ride in broken_rides:
selected_ride = input('That\'s not a ride, put the name of ride you want to check the wait time for or exit to exit: ')
if selected_ride == 'exit':
break
if selected_ride == 'exit':
break
selected_wait_time = attractions['Rides'][selected_ride][4]
output = ''
output = str(attractions['Rides'][selected_ride][3]) + ' people waiting in line for ' + selected_ride + '. There is a ' + str(floor(selected_wait_time / 60)) + ' minute wait time.'
print(output)
wait_timedelta = timedelta(seconds = attractions['Rides'][selected_ride][4])
time_to_ride = now_fixed + wait_timedelta
f_time_to_ride = time_to_ride.strftime('You\'ll get to ride the ride at %I:%M %p\n')
print(f_time_to_ride)
extra_info = ''
if selected_ride != 'a':
extra_info = input('Want a detailed breakdown of the guests at the park? (y/n):')
else:
pass
if extra_info == 'y' or selected_ride == 'a':
extra_info_file = open('extra_info.txt', 'w')
busy_amount_text = ['practically closed.', 'somewhat busy.', 'busy.', 'extremely busy.', 'going to be a pain to get through.']
busy_amount = 0
if (total_guests / (base_guests * park_popularity * weighted_time * weighted_day) * 100) < 10:
pass
elif (total_guests / (base_guests * park_popularity * weighted_time * weighted_day) * 100) < 35:
busy_amount = 1
elif (total_guests / (base_guests * park_popularity * weighted_time * weighted_day) * 100) < 65:
busy_amount = 2
elif (total_guests / (base_guests * park_popularity * weighted_time * weighted_day) * 100) < 90:
busy_amount = 3
else:
busy_amount = 4
f_now_fixed = now_fixed.strftime('%-I:%M%p %A, %B %-d, %Y')
f_now_fixed = f_now_fixed[0:7].lower() + f_now_fixed[7:]
file_write = str(f_now_fixed) + '\nToday the park is ' + str(busy_amount_text[busy_amount]) + '\n\n'
extra_info_file.write(file_write)
guest_type = [0, 0, 0]
for ride in attractions['Rides']:
if attractions['Rides'][ride][0] == 3:
guest_type[0] += attractions['Rides'][ride][3]
elif attractions['Rides'][ride][0] == 2:
guest_type[1] += attractions['Rides'][ride][3]
else:
guest_type[2] += attractions['Rides'][ride][3]
file_write = 'Guest Information:\n- ' + str(total_guests) + ' total guests at the park right now.\n- ' + str(guest_type[0]) + ' big ride guests, ' + str(guest_type[1]) + ' medium ride guests, and ' + str(guest_type[2]) + ' small ride guests.\n- ' + str(total_guests - (guest_type[0] + guest_type[1] + guest_type[2])) + ' guests not on a ride or in line.\n\n'
extra_info_file.write(file_write)
if broken_rides == []:
file_write = 'Ride Information:\n- No broken rides.\n'
extra_info_file.write(file_write)
else:
file_write = 'Ride Information:\n- Broken rides: ' + ', '.join(broken_rides) + '\n'
extra_info_file.write(file_write)
ride_list = []
index = 0
for ride in attractions['Rides']:
ride_list.append(ride)
ride_list[index] = '{:.2f}'.format(attractions['Rides'][ride][4] / 60 / 60) + '#' + ride_list[index]
index += 1
index = 0
format_ride_list = []
for ride in ride_list:
if ride[ride.find('#') + 1::] not in broken_rides:
waittime_format = ride.replace('0', 'a')
waittime_format = waittime_format.replace('1', 'b')
waittime_format = waittime_format.replace('2', 'c')
waittime_format = waittime_format.replace('3', 'd')
waittime_format = waittime_format.replace('4', 'e')
waittime_format = waittime_format.replace('5', 'f')
waittime_format = waittime_format.replace('6', 'g')
waittime_format = waittime_format.replace('7', 'h')
waittime_format = waittime_format.replace('8', 'i')
waittime_format = waittime_format.replace('9', 'j')
format_ride_list.append(waittime_format)
format_ride_list.sort()
else:
pass
recommended_rides = []
for index in range(0, 5):
recommended_rides.append(format_ride_list[index][format_ride_list[index].find('#') + 1::])
popular_rides = []
for index in range(0, 5):
popular_rides.append(format_ride_list[::-1][index][format_ride_list[index].find('#') + 1::])
file_write = '- Recommended Rides: ' + ', '.join(recommended_rides) + '\n- Most Popular Rides: ' + ', '.join(popular_rides) + '\n\n'
extra_info_file.write(file_write)
extra_info_file.write('Ride Wait Times:\n')
for ride in attractions['Rides']:
if ride not in broken_rides:
file_write = '- ' + ride + ': ' + str(attractions['Rides'][ride][3]) + ' guests waiting in line - ' + str(floor(attractions['Rides'][ride][4] / 60)) + ' minute wait time.' + '\n'
else:
file_write = '- ' + ride + ': Out of commission.\n'
extra_info_file.write(file_write)
if selected_ride == 'a':
file_write = '\nAdmin Information:\n- Realitive Capacity: {:.2f}%'.format(total_guests / (base_guests * park_popularity * weighted_time * weighted_day) * 100) + '\n- Guests waiting in line: {:.2f}%\n'.format((guest_type[0] + guest_type[1] + guest_type[2]) / total_guests * 100)
extra_info_file.write(file_write)
file_write = '- Work Efficiency: ' + str(work_eff) + '\n- Day weight: ' + str(day_weights[int(now_fixed.strftime('%w'))]) + '\n- Hour Weight: ' + str(time_weights[now_fixed.hour - 9]) + '\n- base_guests = ' + str(base_guests) + '\n- park_popularity = ' + str(park_popularity)
extra_info_file.write(file_write)
extra_info_file.close()
else:
f_now_fixed = now_fixed.strftime('%I:%M')
am_pm = now_fixed.strftime('%p').lower()
print('The park isn\'t open right now, it opens at 9am and closes at 9pm. The current time is {:s}{:s}.'.format(f_now_fixed, am_pm))