-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
130 lines (122 loc) · 4.12 KB
/
Main.py
File metadata and controls
130 lines (122 loc) · 4.12 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import Functions
import ai
import os
from art import *
from termcolor import colored, cprint
def main_menu():
text=text2art('In', font='block',chr_ignore=True)
text2=text2art('Row', font='block',chr_ignore=True)
cprint(text, "cyan", attrs=["bold"], )
cprint(text2, "cyan", attrs=["bold"])
cprint("by In 3 Calories\n", "red", attrs=["bold"])
gameplay = 0
cprint('(1) Player vs Player\n(2) Player vs AI\n(3) Rules\n(4) Exit', "yellow", attrs=["bold"])
menunumber = int(input(" Give me a number: "))
return menunumber
def pvp():
name1 = input("Player1's name? ")
name2 = input("Player2's name? ")
play = 1
player=1
while play!=0:
board=Functions.start_board()
os.system('clear')
Functions.printboard(board)
game=1
while game==1:
if player==1:
cprint(name1+" turn!", "red", attrs=["bold"])
else:
cprint(name2+" turn!", "green", attrs=["bold"])
coord=Functions.player_move(board)
if coord==None:
return None
board=Functions.move(board,coord,player)
if player==1:
player=2
else:
player=1
os.system('clear')
Functions.printboard(board)
actual_result=Functions.wincheck(board)
if actual_result==1:
cprint(name1+ ' has won!', "red", attrs=["bold"])
game=0
if actual_result==2:
cprint(name2+" has won!" , "green", attrs=["bold"])
game=0
if game==1:
gamedraw=Functions.fullcheck(board)
if gamedraw==1:
cprint("This game is a Draw!", "cyan", attrs=["bold"])
game=0
answer="z"
while answer!="n":
answer= input("Do you want to play again? y or n: ")
if answer=="n":
play=0
break
if answer=="y":
break
def pvA():
name1 = input("Player1's name? ")
play = 1
player=1
while play!=0:
board=Functions.start_board()
os.system('clear')
Functions.printboard(board)
game=1
while game==1:
if player==1:
cprint(name1+" turn!", "red", attrs=["bold"])
coord=Functions.player_move(board)
if coord==None:
return None
else:
coord=ai.ai_move(board)
board=Functions.move(board,coord,player)
if player==1:
player=2
else:
player=1
os.system('clear')
Functions.printboard(board)
actual_result=Functions.wincheck(board)
if actual_result==1:
cprint(name1+ ' has won!', "red", attrs=["bold"])
game=0
if actual_result==2:
cprint("Computer has won! :(", "yellow", attrs=["bold"])
game=0
if game==1:
gamedraw=Functions.fullcheck(board)
if gamedraw==1:
cprint("This game is a Draw!", "cyan", attrs=["bold"])
game=0
answer = "z"
while answer != "n":
answer = input("Do you want to play again? y or n: ")
if answer == "n":
play = 0
break
if answer == "y":
break
os.system('clear')
prog = 1
while prog == 1:
os.system('clear')
game = main_menu()
if game == 1:
pvp()
elif game == 2:
pvA()
elif game == 3:
os.system('clear')
cprint(""" In every game you choose the table size from 3x3 to 10x10\n You play '3 in a row' form 3x3 to 4x4\n'4 in a row' from 5x5 to 7x7 and play\n'5 in a row' from 8x8 to 10x10\n\n If you want to quit anytime during the game type 'quit'\n""","yellow", attrs=["bold"])
easter_egg=input("press ENTER")
elif game == 4:
prog = 0
os.system('clear')
byetext=text2art("Good Bye", font='broadway', chr_ignore=True)
cprint(byetext, 'yellow', attrs=['bold'])