Hello,
im mahan a trainy python programmer and this is my first post!
my tic-tac-toe project is not complete but I will complete it soon.
just wanted to share it and show it in this good forum! the text below is the main file:
im mahan a trainy python programmer and this is my first post!
my tic-tac-toe project is not complete but I will complete it soon.
just wanted to share it and show it in this good forum! the text below is the main file:
##### By Mahan Moosavi #### from main_module import welcome, sep, sec from random import * dict1 = { "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9 } a, b, c, d, e, f, g, h, i = dict1["a"], dict1["b"], dict1["c"], dict1["d"], dict1["e"], dict1["f"], dict1["g"], dict1["h"], dict1["i"] def Cube(): print("_____________________________________________________________________________________________") for line in range(1, 26): if line != 8 or 16: print( "| | | |") if line == 8: print( "|______________________________|______________________________|______________________________|") if line == 16: print( "|______________________________|______________________________|______________________________|") if line == 4: print( f" {a} {b} {c} ") if line == 12: print( f" {d} {e} {f} ") if line == 20: print( f" {g} {h} {i} ") print("_____________________________________________________________________________________________") #### Welcome part #### welcome() start = input("Start: ") selectOption = input("Wanna be Y or X? ==> ") while True: if int(start) == 1: sep(1) if selectOption == "y": computerSelect, computerMove = choice(range(1, 10)), "X" dict3 = sec(computerSelect, computerMove) a, b, c, d, e, f, g, h, i = dict3["a"], dict3["b"], dict3["c"], dict3["d"], dict3["e"], dict3["f"], dict3["g"], dict3["h"], dict3["i"] Cube() dict2 = sec(int(input("Which section?: ")), "Y") a, b, c, d, e, f, g, h, i = dict2["a"], dict2["b"], dict2["c"], dict2["d"], dict2["e"], dict2["f"], dict2["g"], dict2["h"], dict2["i"] Cube() if selectOption == "X": computerSelect, computerMove = choice(range(1, 10)), "Y" dict3 = sec(computerSelect, computerMove) a, b, c, d, e, f, g, h, i = dict3["a"], dict3["b"], dict3["c"], dict3["d"], dict3["e"], dict3["f"], dict3["g"], dict3["h"], dict3["i"] Cube() dict2 = sec(int(input("Which section?: ")), "X") a, b, c, d, e, f, g, h, i = dict2["a"], dict2["b"], dict2["c"], dict2["d"], dict2["e"], dict2["f"], dict2["g"], dict2["h"], dict2["i"] Cube()And this is the module I used:
def welcome(): print("______________________________") print("Welcome to Iranian game \" Dooz \" \n For start the game enter <1>:") print("______________________________") def sep(Type): if Type == 1: print("______________________________") elif Type == 2: print("___________========___________") elif Type == 3: print("------------------------------") elif Type == 4: print("******************************") dict1 = { "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9 } def sec(section,val): if section == 1: dict1["a"] = val if section == 2: dict1["b"] = val if section == 3: dict1["c"] = val if section == 4: dict1["d"] = val if section == 5: dict1["e"] = val if section == 6: dict1["f"] = val if section == 7: dict1["g"] = val if section == 8: dict1["h"] = val if section == 9: dict1["i"] = val return dict1I will be so happy to leave command and tell me some tips to make my small project better.
