Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,33 +12,36 @@ def validate_userInput(user_input):
|
|
| 12 |
if int(user_input) < 1 or int(user_input) > 9:
|
| 13 |
return "Please enter a digit between 1 to 9."
|
| 14 |
else:
|
| 15 |
-
legal_numbers.pop(int(user_input)-1)
|
| 16 |
return legal_numbers
|
| 17 |
else:
|
| 18 |
return "Please enter a digit between 1 to 9."
|
| 19 |
|
| 20 |
-
def display_board():
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
def reset_legalNumbers():
|
| 44 |
legal_numbers = [1,2,3,4,5,6,7,8,9]
|
|
@@ -54,10 +57,6 @@ st.header("Python - Tic Tac Toe")
|
|
| 54 |
user_input=get_userInput()
|
| 55 |
display_board()
|
| 56 |
|
| 57 |
-
#UI Buttons
|
| 58 |
-
submit=st.button('Submit')
|
| 59 |
-
replay=st.button('Replay')
|
| 60 |
-
|
| 61 |
#Button functionality
|
| 62 |
if submit:
|
| 63 |
st.subheader("")
|
|
@@ -70,6 +69,10 @@ if replay:
|
|
| 70 |
display_board()
|
| 71 |
reset_legalNumbers()
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
#After User Interaction
|
| 74 |
response=validate_userInput(user_input)
|
| 75 |
|
|
|
|
| 12 |
if int(user_input) < 1 or int(user_input) > 9:
|
| 13 |
return "Please enter a digit between 1 to 9."
|
| 14 |
else:
|
| 15 |
+
legal_numbers = legal_numbers.pop(int(user_input)-1)
|
| 16 |
return legal_numbers
|
| 17 |
else:
|
| 18 |
return "Please enter a digit between 1 to 9."
|
| 19 |
|
| 20 |
+
def display_board(text):
|
| 21 |
+
if len(text) == 0:
|
| 22 |
+
col1, col2, col3 = st.columns(3)
|
| 23 |
+
col4, col5, col6 = st.columns(3)
|
| 24 |
+
col7, col8, col9 = st.columns(3)
|
| 25 |
+
with col1:
|
| 26 |
+
st.text("X")
|
| 27 |
+
with col2:
|
| 28 |
+
st.text("O")
|
| 29 |
+
with col3:
|
| 30 |
+
st.text("...")
|
| 31 |
+
with col4:
|
| 32 |
+
st.text(" X ")
|
| 33 |
+
with col5:
|
| 34 |
+
st.text(" O ")
|
| 35 |
+
with col6:
|
| 36 |
+
st.text(" ... ")
|
| 37 |
+
with col7:
|
| 38 |
+
st.text(" X ")
|
| 39 |
+
with col8:
|
| 40 |
+
st.text(" O ")
|
| 41 |
+
with col9:
|
| 42 |
+
st.text(" ... ")
|
| 43 |
+
else:
|
| 44 |
+
|
| 45 |
|
| 46 |
def reset_legalNumbers():
|
| 47 |
legal_numbers = [1,2,3,4,5,6,7,8,9]
|
|
|
|
| 57 |
user_input=get_userInput()
|
| 58 |
display_board()
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
#Button functionality
|
| 61 |
if submit:
|
| 62 |
st.subheader("")
|
|
|
|
| 69 |
display_board()
|
| 70 |
reset_legalNumbers()
|
| 71 |
|
| 72 |
+
#UI Buttons
|
| 73 |
+
submit=st.button('Submit')
|
| 74 |
+
replay=st.button('Replay')
|
| 75 |
+
|
| 76 |
#After User Interaction
|
| 77 |
response=validate_userInput(user_input)
|
| 78 |
|