-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtick_tack.py
58 lines (52 loc) · 1.78 KB
/
tick_tack.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
'''
Author : Izak Hearn
Date : 13/09/2022
Assignment : W01 Prove: Developer
Description : This program is a game of tick tack toe
'''
#Import the draw board file and use the class to draw the board
import gamefiles.draw_board as db
def main() :
#Get Player 1's name
player1 = input("Player 1, enter your name: ")
#Get Player 1's symbol
symbol1 = input("Player 1, enter your symbol: ")
#Get Player 2's name
player2 = input("Player 2, enter your name: ")
#Get Player 2's symbol
symbol2 = input("Player 2, enter your symbol: ")
#Check if the symbols are the same
while checkSymbols(symbol1,symbol2) == False :
print("Symbols Must Be Different")
symbol2 = input("Player 2, enter your symbol: ")
#Get the width of the board
width = GetInt("Enter the width of the board: ")
#Get the height of the board
height = GetInt("Enter the height of the board: ")
#Board must be at least 3x3
while checkBoardSize(width,height) == False :
print("Board Must Be At Least 3x3")
width = GetInt("Enter the width of the board: ")
height = GetInt("Enter the height of the board: ")
#Create a new instance of the draw board class
board = db.DrawBoard(width, height, player1, player2, symbol1, symbol2)
#Get the players moves
board.getMoves()
#
def GetInt(prompt) :
while True :
try :
value = int(input(prompt))
return value
except ValueError :
print("Invalid Value Entered. Value Must Be A Whole Number")
def checkSymbols(symbol1,symbol2) :
if symbol1 == symbol2 :
return False
return True
def checkBoardSize(width,height) :
if width < 3 or height < 3 :
return False
return True
if __name__ == "__main__" :
main()