awacke1 commited on
Commit
ab1cbaa
·
1 Parent(s): 76053c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -21
app.py CHANGED
@@ -104,18 +104,12 @@ def boggle(size):
104
 
105
  return board, words
106
 
107
-
108
- def play_boggle(board, words, time_limit):
109
  """Function for playing the Boggle game"""
110
- start_time = time.time()
111
- remaining_time = time_limit
112
- form_key = 0
113
-
114
- with st.form(key=f"new_word_{form_key}"):
115
  new_word = st.text_input("Enter a new word:")
116
  submit_button = st.form_submit_button("Submit")
117
-
118
- while remaining_time > 0:
119
  if submit_button:
120
  if len(new_word) >= 3 and new_word not in words and validate_word(new_word.upper(), board):
121
  words.add(new_word)
@@ -124,26 +118,16 @@ def play_boggle(board, words, time_limit):
124
  st.write("Word already used!")
125
  else:
126
  st.write("Invalid word. Try again.")
127
-
128
  st.write("Here are your words:")
129
  st.write(words)
130
- st.write("Time remaining:", remaining_time)
131
- time.sleep(1)
132
- remaining_time = int(time_limit - (time.time() - start_time))
133
- form_key += 1
134
-
135
- with st.form(key=f"new_word_{form_key}"):
136
  new_word = st.text_input("Enter a new word:")
137
  submit_button = st.form_submit_button("Submit")
138
 
139
- st.write("Time's up! Here are your final words:")
140
- st.write(words)
141
-
142
-
143
 
144
  if __name__ == "__main__":
145
  board, words = boggle(7)
146
- play_boggle(board, words, 60)
147
 
148
  #if __name__ == "__main__":
149
  # boggle(7, 60)
 
104
 
105
  return board, words
106
 
107
+ def play_boggle(board, words):
 
108
  """Function for playing the Boggle game"""
109
+ with st.form(key="new_word"):
 
 
 
 
110
  new_word = st.text_input("Enter a new word:")
111
  submit_button = st.form_submit_button("Submit")
112
+ while True:
 
113
  if submit_button:
114
  if len(new_word) >= 3 and new_word not in words and validate_word(new_word.upper(), board):
115
  words.add(new_word)
 
118
  st.write("Word already used!")
119
  else:
120
  st.write("Invalid word. Try again.")
 
121
  st.write("Here are your words:")
122
  st.write(words)
123
+ with st.form(key="new_word"):
 
 
 
 
 
124
  new_word = st.text_input("Enter a new word:")
125
  submit_button = st.form_submit_button("Submit")
126
 
 
 
 
 
127
 
128
  if __name__ == "__main__":
129
  board, words = boggle(7)
130
+ play_boggle(board, words)
131
 
132
  #if __name__ == "__main__":
133
  # boggle(7, 60)