i use vscode, and the .run extention is being weird, so it might be that, but idk. if you have any ideas on how to make this work, please let me know.
from random import randint
import time
global Save_R1_1
global Save_R2_1
global Save_R3_1
global Save_R1_2
global Save_R2_2
global Save_R3_2
def c_turn(Save_R1_1, Save_R2_1, Save_R3_1):
def c_move(R1, R2, R3):
randomizer1 = randint(1, 3)
randomizer2 = randint(1, 3)
if randomizer1 == 1:
if R1[randomizer2 - 1] == "_ ": #check later in turn sequence to see if spot is not open
R1[randomizer2 - 1] = "O"
Save_R1_1 = R1
Save_R2_1 = R2
Save_R3_1 = R3
elif randomizer1 == 2:
if R2[randomizer2 - 1] == "_ ": #check later in turn sequence to see if spot is not open
R2[randomizer2 - 1] = "O"
Save_R1_1 = R1
Save_R2_1 = R2
Save_R3_1 = R3
elif randomizer1 == 3:
if R2[randomizer2 - 1] == "_ ": #check later in turn sequence to see if spot is not open
R2[randomizer2 - 1] = "O"
Save_R1_1 = R1
Save_R2_1 = R2
Save_R3_1 = R3
return
#Start computer move
#see, i first define vars
#i then exicute the actual move before the while loop, to establish secondary board saves for the while loop
#after that i initiate the while loop, eliminating any possibility that the computer will not move
#now i just need to do a wincheck… a very, very lengthly wincheck, including every possible win scinerio, that will take forever to write.
#well, that wasnt too bad… thank god for copy and paste. now i just print the board and move on to the players turn.
win = "tbd"
if Save_R1_1[0] and Save_R2_1[0] and Save_R3_1[0] and Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] and Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] != "_ ":
print("Tie. cya.")
exit()
Save_R1_2 = Save_R1_1
Save_R2_2 = Save_R2_1
Save_R3_2 = Save_R3_1
c_move(Save_R1_1, Save_R2_1, Save_R3_1)
while Save_R1_2 == Save_R1_1 and Save_R2_2 == Save_R2_1 and Save_R3_2 == Save_R3_1:
c_move(Save_R1_1, Save_R2_1, Save_R3_1)
if Save_R1_1[1] and Save_R1_1[2] and Save_R1_1[3] == "O ": win = "O"
elif Save_R2_1[1] and Save_R2_1[2] and Save_R2_1[3] == "O ": win = "O"
elif Save_R3_1[1] and Save_R3_1[2] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[1] and Save_R2_1[2] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[3] and Save_R2_1[2] and Save_R3_1[1] == "O ": win = "O"
elif Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] == "O ": win = "O"
elif Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] == "O ": win = "O"
elif Save_R1_1[3] and Save_R2_1[3] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[1] and Save_R1_1[2] and Save_R1_1[3] == "X ": win = "X"
elif Save_R2_1[1] and Save_R2_1[2] and Save_R2_1[3] == "X ": win = "X"
elif Save_R3_1[1] and Save_R3_1[2] and Save_R3_1[3] == "X ": win = "X"
elif Save_R1_1[1] and Save_R2_1[2] and Save_R3_1[3] == "X ": win = "X"
elif Save_R1_1[3] and Save_R2_1[2] and Save_R3_1[1] == "X ": win = "X"
elif Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] == "X ": win = "X"
elif Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] == "X ": win = "X"
elif Save_R1_1[3] and Save_R2_1[3] and Save_R3_1[3] == "X ": win = "X"
if win == "X":
print("Dang, look, you won...")
time.sleep(1)
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
exit()
elif win == "O":
print("HAHA, look, i won!")
time.sleep(1)
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
exit()
print("your turn!")
return Save_R1_1 and Save_R2_1 and Save_R3_1
def p_turn(Save_R1_1, Save_R2_1, Save_R3_1):
win = "tbd"
time.sleep(1)
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
if Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] and Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] and Save_R1_1[3] and Save_R2_1[3] and Save_R3_1[3] != "_ ":
print("Tie. cya.")
exit()
UI_X = input("What row would you like to move in? 1/2/3: ")
UI_Y = input("And what collum? 1/2/3: ")
if UI_X == "1":
Save_R1_1[int(UI_Y)]
if UI_X == "2":
Save_R2_1[int(UI_Y)]
if UI_X == "3":
Save_R3_1[int(UI_Y)]
if Save_R1_1[1] and Save_R1_1[2] and Save_R1_1[3] == "O ": win = "O"
elif Save_R2_1[1] and Save_R2_1[2] and Save_R2_1[3] == "O ": win = "O"
elif Save_R3_1[1] and Save_R3_1[2] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[1] and Save_R2_1[2] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[3] and Save_R2_1[2] and Save_R3_1[1] == "O ": win = "O"
elif Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] == "O ": win = "O"
elif Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] == "O ": win = "O"
elif Save_R1_1[3] and Save_R2_1[3] and Save_R3_1[3] == "O ": win = "O"
elif Save_R1_1[1] and Save_R1_1[2] and Save_R1_1[3] == "X ": win = "X"
elif Save_R2_1[1] and Save_R2_1[2] and Save_R2_1[3] == "X ": win = "X"
elif Save_R3_1[1] and Save_R3_1[2] and Save_R3_1[3] == "X ": win = "X"
elif Save_R1_1[1] and Save_R2_1[2] and Save_R3_1[3] == "X ": win = "X"
elif Save_R1_1[3] and Save_R2_1[2] and Save_R3_1[1] == "X ": win = "X"
elif Save_R1_1[1] and Save_R2_1[1] and Save_R3_1[1] == "X ": win = "X"
elif Save_R1_1[2] and Save_R2_1[2] and Save_R3_1[2] == "X ": win = "X"
elif Save_R1_1[3] and Save_R2_1[3] and Save_R3_1[3] == "X ": win = "X"
if win == "X":
print("Dang, look, you won...")
time.sleep(1)
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
exit()
elif win == "O":
print("HAHA, look, i won!")
time.sleep(1)
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
exit()
elif win == "tbd":
print(Save_R1_1)
print(Save_R2_1)
print(Save_R3_1)
return
#begin syntax
print(“welcome to tic tac toe!”)
time.sleep(1)
print(“Im O, youre X! ill go first.”)
time.sleep(1)
Save_R1_1 = ["_ ", "_ ", "_ "]
Save_R2_1 = ["_ ", "_ ", "_ "]
Save_R3_1 = ["_ ", "_ ", "_ "]
c_turn(Save_R1_1, Save_R2_1, Save_R3_1)
p_turn(Save_R1_1, Save_R2_1, Save_R3_1)