|
import streamlit as st |
|
import pandas as pd |
|
from datetime import date, timedelta |
|
import random |
|
|
|
|
|
|
|
def create_schedule(num_teams, num_conferences, num_inter_games): |
|
"""Create the entire schedule based on user inputs.""" |
|
full_schedule = [] |
|
|
|
|
|
for i in range(num_conferences): |
|
conference_name = chr(65 + i) |
|
combined_schedule = combine_schedules(conference_name, num_teams, num_inter_games) |
|
schedule_with_dates = assign_dates_to_matches_v2(combined_schedule) |
|
|
|
for match in schedule_with_dates: |
|
full_schedule.append({ |
|
"Team 1": match[0], |
|
"Team 2": match[1], |
|
"Date": match[2] |
|
}) |
|
|
|
return pd.DataFrame(full_schedule) |
|
|
|
|
|
|
|
st.title("Basketball Game Schedule Generator") |
|
|
|
|
|
st.header("Configuration") |
|
|
|
num_teams = st.number_input("Number of teams per conference:", min_value=2, value=10) |
|
num_conferences = st.number_input("Number of conferences:", min_value=2, value=4) |
|
num_inter_games = st.number_input("Number of inter-conference games per team:", min_value=1, value=3) |
|
|
|
commissioners = st.multiselect("Add commissioners:", options=[], default=[]) |
|
|
|
add_commissioner = st.text_input("New commissioner name:") |
|
if add_commissioner: |
|
commissioners.append(add_commissioner) |
|
|
|
|
|
if st.button("Generate Schedule"): |
|
global schedule_df |
|
schedule_df = create_schedule(num_teams, num_conferences, num_inter_games) |
|
|
|
|
|
st.header("View Schedule") |
|
conference_selector = st.selectbox("Select conference to view schedule:", options=["All"] + [f"Conference {chr(65+i)}" for i in range(num_conferences)]) |
|
if conference_selector == "All": |
|
st.dataframe(schedule_df) |
|
else: |
|
filtered_schedule = schedule_df[(schedule_df["Team 1"].str.startswith(conference_selector)) | (schedule_df["Team 2"].str.startswith(conference_selector))] |
|
st.dataframe(filtered_schedule) |
|
|
|
|
|
|