nonstopiodemo commited on
Commit
9b18bf4
Β·
verified Β·
1 Parent(s): 5eca34b

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +8 -8
  2. requirements.txt +3 -0
  3. streamlit_app.py +50 -0
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
- title: Tick Tack Toe
3
- emoji: πŸ“‰
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: streamlit
7
- sdk_version: 1.38.0
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: tick-tack-toe
3
+ emoji: πŸš€
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: streamlit
7
+ sdk_version: "1.10.0"
8
+ app_file: streamlit_app.py
9
  pinned: false
10
  ---
11
+ # tick-tack-toe
12
+ This is a Streamlit app generated and deployed automatically.
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ altair==4.2.0
3
+ vega_datasets
streamlit_app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def check_winner(board, player):
4
+ for row in board:
5
+ if all([cell == player for cell in row]):
6
+ return True
7
+
8
+ for col in range(3):
9
+ if all([board[row][col] == player for row in range(3)]):
10
+ return True
11
+
12
+ if all([board[i][i] == player for i in range(3)]) or all([board[i][2 - i] == player for i in range(3)]):
13
+ return True
14
+
15
+ return False
16
+
17
+ def main():
18
+ st.title("Tick Tack Toe Game")
19
+
20
+ board = [[' ' for _ in range(3)] for _ in range(3)]
21
+ player = 'X'
22
+
23
+ st.write("Player to move: ", player)
24
+
25
+ for i in range(3):
26
+ st.write(board[i])
27
+
28
+ while True:
29
+ row = st.number_input("Enter row (0, 1, 2): ", min_value=0, max_value=2)
30
+ col = st.number_input("Enter column (0, 1, 2): ", min_value=0, max_value=2)
31
+
32
+ if board[row][col] == ' ':
33
+ board[row][col] = player
34
+
35
+ if check_winner(board, player):
36
+ st.write(f"Player {player} wins!")
37
+ break
38
+
39
+ if all([cell != ' ' for row in board for cell in row]):
40
+ st.write("It's a tie!")
41
+ break
42
+
43
+ player = 'O' if player == 'X' else 'X'
44
+ st.write("Player to move: ", player)
45
+
46
+ for i in range(3):
47
+ st.write(board[i])
48
+
49
+ if __name__ == '__main__':
50
+ main()