import random
import time
def main():
    print(" _    _         _                  _               ")
    print("| |_ (_) ___ | |_     __ _   ___ | |_    ___   ___ ")
    print("| __|| | / __| | __| / _` | / __| | __| / _ \ / _ \ ")
    print("| |_ | || (__ | |_ | (_| || (__ | |_ | (_) || __/")
    print(" \__||_| \___| \__| \__,_| \___| \__| \___/ \___|")
    choose_mode= input("choose your mode singleplayer=s or multiplayer=m: ")
    if choose_mode == "s":
        name= input("hello what is your name: ")
        print("welcome " + name +" lets play tic tac toe")
        singleplayer()
    if choose_mode == 'm':
        name= input("what is player one's name: ")
        print("welcom e " + name +" lets play tic tac toe")
        second_welcome= input("what is player two's name: ")
        print("welcome " + second_welcome +" lets play tic tac toe")
        player1()
table = [0,1,2,3,4,5,6,7,8]
winner= 'n'
def show():
    print( table[0],"▐",table[1],"▐",table[2])
    print("▄▄▄▄▄▄▄▄▄▄▄")
    print( table[3],"▐",table[4],"▐",table[5])
    print("▄▄▄▄▄▄▄▄▄▄▄")
    print( table[6],"▐",table[7],"▐",table[8],)
    already_guessed =[]
def winCheck(char):
    lines = ["012","345","678","036","147","258","048","642"]
    match = char * 3
    for line in lines:
        check = str(table[int(line[0])]) + str(table[int(line[1])]) + str(table[int(line[2])])
        if check == match:
            return True
            break
def player1():
    count = 0
    while True:
        show()
        choose= input("player 1 pick a place: ")
        choose= int(choose)
        if table[choose] !="x" and table[choose] !="o":
            table[choose] ="x"
            if winCheck("x") == True:
                    print ("player one wins")
                    show()
                    exite= input("press enter to exit: ")
                    if exite == "":
                        exit()
        if table[choose] == "x":
            count +=1
        if count == 9:
                print ("tie")
                show()
                exite= input("press enter to exit: ")
                if exite == "":
                    exit()
        while True:
            show()
            player2= input("player 2 pick a place: ")
            player2= int(player2)
            if table[player2] !="o" and table[player2] !="x":
                table[player2] = "o"
                if winCheck("o") == True:
                    print ("player two wins")
                    show()
                    winner = "y"
                    exite= input("press enter to exit: ")
                    if exite == "":
                        exit()
            if table[player2] == "o":
                count +=1
            if count == 9:
                print ("tie")
                show()
                exite= input("press enter to exit: ")
                if exite == "":
                    exit()
            break;
def singleplayer():
    while True:
        show()
        choose= input("pick a placeplace: ")
        choose= int(choose)
         if table[choose] !="x" and table[choose] !="o":
             table[choose] ="x"
             if winCheck("x") == True:
                     print ("You won!")
                     show()
                     winner = "y"
                     exite= input("press enter to exit: ")
                     if exite == "":
                         exit()
         while True:
             random.seed()
             player2 = random.randint(0,8)
             if table[player2] !="o" and table[player2] !="x":
                 table[player2] = "o"
                 if winCheck("o") == True:
                     print ("You lost")
                     winner = "y"
                     exite= input("press enter to exit: ")
                     if exite == "":
                         exit()
main()