-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameplay.py
73 lines (56 loc) · 1.91 KB
/
gameplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# WHILE LOOP TO KEEP RUNNING THE GAME
print('Welcome to TIC TAC TOE')
while True
#play the game
## SET EVERYTHING UP(BOARD, WHOS FIRST, CHOOSE MAKERS X,O)
the_board = [' ']*10
player1_marker,player2_marker = player_input()
turn = choose_first()
print(turn + 'will go first')
play_game = input('Ready to play? y or n? ')
if play_game == 'y':
game_on = True
else:
game_on = False
# game play
while game_on:
if turn == 'player1':
# show the board
display_board(the_board)
# choose a position
position = player_choice(the_board)
# place the marker on the position
place_marker(the_board,player1_marker,position)
#chcek if they won
if win_check(the_board,player1_marker):
display_board(the_board)
print('PLAYER 1 HAS WON!!')
game_on = False
else:
if full_board_check(the_board):
display_board(the_board)
print("TIE GAME!")
game_on = False
else:
turn = 'player 2'
else:
# show the board
display_board(the_board)
# choose a position
position = player_choice(the_board)
# place the marker on the position
place_marker(the_board,player2_marker,position)
#chcek if they won
if win_check(the_board,player2_marker):
display_board(the_board)
print('PLAYER 2 HAS WON!!')
game_on = False
else:
if full_board_check(the_board):
display_board(the_board)
print("TIE GAME!")
game_on = False
else:
turn = 'player1'
if not replay():
break