-
-
Save HohShenYien/5295ad0e775637c144506d59164a4cf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sorce:http://patorjk.com/software/taag/#p=display&f=Big%20Money-sw&t=TIC%20TAC | |
w1=""" | |
________ ______ ______ | |
/ |/ | / \ | |
$$$$$$$$/ $$$$$$/ /$$$$$$ | | |
$$ | $$ | $$ | $$/ | |
$$ | $$ | $$ | | |
$$ | $$ | $$ | __ | |
$$ | _$$ |_ $$ \__/ | | |
$$ | / $$ |$$ $$/ | |
$$/ $$$$$$/ $$$$$$/ | |
""" | |
w2=""" | |
________ ______ ______ | |
/ |/ \ / \ | |
$$$$$$$$//$$$$$$ |/$$$$$$ | | |
$$ | $$ |__$$ |$$ | $$/ | |
$$ | $$ $$ |$$ | | |
$$ | $$$$$$$$ |$$ | __ | |
$$ | $$ | $$ |$$ \__/ | | |
$$ | $$ | $$ |$$ $$/ | |
$$/ $$/ $$/ $$$$$$/ | |
""" | |
w3=""" | |
________ ______ ________ | |
/ |/ \ / | | |
$$$$$$$$//$$$$$$ |$$$$$$$$/ | |
$$ | $$ | $$ |$$ |__ | |
$$ | $$ | $$ |$$ | | |
$$ | $$ | $$ |$$$$$/ | |
$$ | $$ \__$$ |$$ |_____ | |
$$ | $$ $$/ $$ | | |
$$/ $$$$$$/ $$$$$$$$/ | |
""" | |
print("{} {}\n{}".format(w1,w2,w3)) | |
def win(set): | |
if set[1]==True: | |
if set[5]==True: | |
if set[9]==True: | |
return True | |
if set[4]==True: | |
if set[7]==True: | |
return True | |
if set[2]==True : | |
if set[3]==True: | |
return True | |
if set[4]==True and set[5]==True and set[6]==True: | |
return True | |
if set[2]==True and set[5]==True and set[8]==True: | |
return True | |
if set[3]==True and set[5]==True and set[7]==True: | |
return True | |
if set[7]==True and set[8]==True and set[9]==True: | |
return True | |
if set[3]==True and set[6]==True and set[9]==True: | |
return True | |
if set[1]==False: | |
if set[5]==False: | |
if set[9]==False: | |
return True | |
if set[4]==False: | |
if set[7]==False: | |
return True | |
if set[2]==False : | |
if set[3]==False: | |
return True | |
if set[4]==False and set[5]==False and set[6]==False: | |
return True | |
if set[2]==False and set[5]==False and set[8]==False: | |
return True | |
if set[3]==False and set[5]==False and set[7]==False: | |
return True | |
if set[7]==False and set[8]==False and set[9]==False: | |
return True | |
if set[3]==False and set[6]==False and set[9]==False: | |
return True | |
def pict(list): | |
print( | |
""" | |
| | | |
{} | {} | {} | |
_____|_____|_____ | |
| | | |
{} | {} | {} | |
_____|_____|_____ | |
| | | |
{} | {} | {} | |
| | | |
""".format(list[1],list[2],list[3],list[4],list[5],list[6],list[7],list[8],list[9])) | |
symbol=[" O"," X"] | |
num=[123456789] | |
backup=[[]]*10 | |
response=input("Do you want to play Tic Tac Toe?(yes/no) ") | |
while not (response=="yes" or response=="no"): | |
response=input("Please enter only 'yes' or 'no' ") | |
answer=("1","2","3","4","5","6","7","8","9") | |
while response=="yes": | |
board=[[]]*10 | |
n=1 | |
setup=[" 0"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9"] | |
print(pict(setup)) | |
for x in range(9): | |
print("Round {}".format(n)) | |
y=input("Please input your position (1-9): ") | |
while str(y) not in answer: | |
y=input("Only from 1 to 9 ") | |
y=int(y) | |
while board[y]!=[]: | |
y=input("Do not select repeated tile ") | |
while str(y) not in answer: | |
y=input("Only from 1 to 9 ") | |
y=int(y) | |
if n%2==0: | |
setup[y]=" X" | |
board[y]=False | |
else: | |
setup[y]=" O" | |
board[y]=True | |
print(pict(setup)) | |
if win(board): | |
if n%2==0: | |
print("2nd player won") | |
break | |
else: | |
print("1st player won") | |
break | |
n+=1 | |
if not win(board): | |
print("draw!") | |
print(""" | |
____ _ | |
| _ \ _ __ __ ___ _| | | |
| | | | '__/ _` \ \ /\ / / | | |
| |_| | | | (_| |\ V V /|_| | |
|____/|_| \__,_| \_/\_/ (_) | |
""") | |
response=input("Do you still want to play Tic Tac Toe?(yes/no)") | |
while not (response=="yes" or response=="no"): | |
response=input("Please enter only 'yes' or 'no' ") | |
print("Thank you for playing") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment