44# GAME LOGIC
55# --------------------------------------------------------------------------
66
7- # global constants
7+ # CREATING CONSTANTS AND VARIABLES
88MARK1 = 'O'
99MARK2 = 'X'
1010
1313player1 = ''
1414player2 = ''
1515current_player_identifier = 0
16+ # winning conditions
1617wins = [
1718 [(0 , 0 ), (0 , 1 ), (0 , 2 )],
1819 [(1 , 0 ), (1 , 1 ), (1 , 2 )],
2324 [(0 , 0 ), (1 , 1 ), (2 , 2 )],
2425 [(0 , 2 ), (1 , 1 ), (2 , 0 )]
2526]
27+ # places to mark. If it is false, user can place his mark else not
2628check_table = [[False , False , False ],
2729 [False , False , False ],
2830 [False , False , False ]]
31+ # variable to stop users form placing their marks
2932game_over = False
3033
34+ # DEFINING FUNCTIONS
35+
3136
3237def set_initials (name1 , name2 ):
3338 global current_mark , player1 , player2 , current_player_identifier
@@ -152,7 +157,8 @@ def display_game_board(val1, val2):
152157# GAME User Interface
153158# --------------------------------------------------------------------------
154159
155- # font styles
160+ # UI VARIABLES AND CONSTANTS
161+ # fonts
156162BODY = ("Arial" , 16 , "normal" )
157163HEAD = ("Courier" , 20 , "bold" )
158164GIANT = ("Arial" , 50 , "bold" )
@@ -166,7 +172,8 @@ def display_game_board(val1, val2):
166172rows = {0 : 0 , 2 : 1 , 4 : 2 }
167173cols = {1 : 0 , 3 : 1 , 5 : 2 }
168174
169- # Create a window
175+ # CREATE WIDGETS
176+ # create the window
170177window = tk .Tk ()
171178window .title ("Welcome to Tic Tac Toe" )
172179window .geometry ("640x427" )
0 commit comments