Python 巨蟒用海龟抽搐。(用户必须在相应的方框中输入数字。)

Python 巨蟒用海龟抽搐。(用户必须在相应的方框中输入数字。),python,module,tic-tac-toe,turtle-graphics,Python,Module,Tic Tac Toe,Turtle Graphics,为什么refresh2函数没有做任何事情?它应该检查O玩家是否获胜,但它没有这样做。我真的需要帮助才能让第二个刷新功能正常工作。任何帮助都将不胜感激。此外,在玩家获胜后,应该在玩家获胜的地方划一条线。确实如此,但它是非常不准确和扭曲的。请打电话通知我powdercheeze@gmail.com如果你周五有任何答案 from turtle import * from os import * import math list1 = {1: (-100,100),2: (0,100), 3: (100

为什么refresh2函数没有做任何事情?它应该检查O玩家是否获胜,但它没有这样做。我真的需要帮助才能让第二个刷新功能正常工作。任何帮助都将不胜感激。此外,在玩家获胜后,应该在玩家获胜的地方划一条线。确实如此,但它是非常不准确和扭曲的。请打电话通知我powdercheeze@gmail.com如果你周五有任何答案

from turtle import *
from os import *
import math
list1 = {1: (-100,100),2: (0,100), 3: (100,100), 4: (-100,0), 5: (0,0), 6: (100,0), 7: (-100,-100), 8: (0,-100), 9: (100,-100)}
list2 = [];list3 = [];list4 = {1: (-100,100),2: (0,100), 3: (100,100), 4: (-100,0), 5: (0,0), 6: (100,0), 7: (-100,-100), 8: (0,-100), 9: (100,-100)}
t = Turtle();
def turtle1():
    t.home();resetscreen()
    t.speed(10000);t.up();t.backward(150);t.pendown();t.forward(300);t.left(90);t.up();t.forward(1/3*300);t.pendown();t.left(90);t.forward(300);t.right(180)
    t.forward(100);t.left(90);t.forward(100);t.right(180);t.forward(300);t.right(180);
    t.forward(100)
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(100)
    t.right(180)
    t.forward(300)
def input1():
    a = int(input("X player, enter a square: "))
    if a in list1:
        t = Turtle();t.up();t.setposition(list1[a]);t.left(90);t.forward(50);t.pendown();t.right(45);
        t.forward(40*math.sqrt(2));
        t.left(180);
        t.forward(80*math.sqrt(2))
        t.left(180)
        t.forward(40*math.sqrt(2))
        t.right(90)
        t.forward(40*math.sqrt(2))
        t.right(180)
        t.forward(80*math.sqrt(2))
        list1.pop(a)
        list2.append(a)
        refresh2() 
    if a not in list1:
        print("Enter a valid square, or one that hasn't been taken yet.")
        input1()
def input2():
    b = int(input("O player, enter a square: "))
    if b in list1:
        c = Turtle();c.up();c.setposition(list1[b]);
        c.down()
        c.circle(47)
        list1.pop(b)
        input1()
        list3.append(b)
        refresh();refresh2() 
    if b not in list1:
        print("Enter a valid square, or one that hasn't been taken yet.")
        input2()
def refresh():
    global list2;global list1;
    if 1 in list2 and 2 in list2 and 3 in list2 or 4 in list2 and 5 in list2 and 6 in list2 or 7 in list2 and 8 in list2 and 9 in list2: 
        print("The X Player Won! ");list2.sort();t.up();t.left(45);t.forward(80*math.sqrt(2));t.setposition(list4[int(list2[1])]);t.down();t.goto(list4[list2[int(len(list2)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list2 = [];list1 = list4;turtle1();input1()
    if 1 in list2 and 4 in list2 and 7 in list2 or 2 in list2 and 5 in list2 and 8 in list2 or 3 in list2 and 6 in list2 and 9 in list2:
        print("The X Player Won! ");list2.sort();t.up();t.left(45);t.forward(80*math.sqrt(2));t.setposition(list4[int(list2[1])]);t.down();t.goto(list4[list2[int(len(list2)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list2 = [];list1 = list4;turtle1();input1()
    if 1 in list2 and 5 in list2 and 9 in list2 or 3 in list2 and 5 in list2 and 7 in list2:
        print("The X Player Won! ");list2.sort();t.up();t.left(45);t.forward(80*math.sqrt(2));t.setposition(list4[int(list2[1])]);t.down();t.goto(list4[list2[int(len(list2)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list2 = [];list1 = list4;turtle1();input1()
    if len(list1) == 0:print("Tie!")
    else:
        input2()
def refresh2():
    if 1 in list2 and 2 in list2 and 3 in list2 or 4 in list2 and 5 in list2 and 6 in list2 or 7 in list2 and 8 in list2 and 9 in list2: 
        print("The O Player Won! ");list2.sort();t.up();t.left(90);t.forward(50);t.setposition(list4[int(list2[1])]);t.down();t.goto(list4[list2[int(len(list2)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list2 = [];list1 = list4;turtle1();input1()
    if 1 in list3 and 4 in list3 and 7 in list3 or 2 in list3 and 5 in list3 and 8 in list3 or 3 in list3 and 6 in list3 and 9 in list3:
        print("The O Player Won! ");list3.sort();t.up();t.left(90);t.forward(50);t.setposition(list4[int(list3[1])]);t.down();t.goto(list4[list3[int(len(list3)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list3 = [];list1 = list4;turtle1();input1()
    if 1 in list3 and 5 in list3 and 9 in list3 or 3 in list3 and 5 in list3 and 7 in list3:
        print("The O Player Won! ");list3.sort();t.up();t.left(90);t.forward(50);t.setposition(list4[int(list3[1])]);t.down();t.goto(list4[list3[int(len(list3)-1)]])
        z = input("Do you want to play again? ")
        if z == "y" or z == "Y": list3 = [];list1 = list4;turtle1();input1()
    if len(list1) == 0:print("Tie!")
turtle1()
while True:
    input1()
    input2()

请打电话通知我powdercheeze@gmail.com如果你在周五之前有任何答案,你实际上是在要求一个答案,至少试着更礼貌一些。你能解释一下每个列表应该做什么吗?你认为刷新功能在做什么?它有错误吗?此外,这不是你如何设计一个井字游戏。答案只在这里提供。这就是这个网站的目的。帮助每个人&而不仅仅是一个人。此外,礼貌一点总是有帮助的:我在11年级,这是我能做的最好的:
#-------------------------------------------------------------------------------
# Name:        TIC-TAC-TOE
#-------------------------------------------------------------------------------
import turtle
turtle.speed(0)

def MakeCircle():
    turtle.pencolor("black")
    turtle.circle(12)
    turtle.pencolor("white")

def MakeCross():
    turtle.pencolor("black")
    turtle.lt(45)
    turtle.forward(19)
    turtle.rt(180)
    turtle.forward(9.5)
    turtle.rt(90)
    turtle.forward(9.5)
    turtle.rt(180)
    turtle.forward(19)
    turtle.pencolor("white")

def MakeTable():
    turtle.forward (90)
    turtle.rt(180)
    turtle.forward(60)
    turtle.lt(90)
    turtle.forward(60)
    turtle.lt(180)
    turtle.forward(90)
    turtle.lt(180)
    turtle.forward(60)
    turtle.lt(90)
    turtle.forward(60)
    turtle.lt(180)
    turtle.forward(90)
    turtle.lt(180)
    turtle.forward(60)
    turtle.lt(90)
    turtle.forward(60)
    turtle.lt(180)
    turtle.forward(90)
    turtle.pencolor("white")
    turtle.goto(45,-15)

def PlayFirstCircle():
    play=raw_input(" CIRCLE : Where do you want to play? : ")
    i=1
    if play == "A":
        play = (4,15)
    elif play == "B":
        play = (4,-15)
    elif play == "C":
        play = (4,-45)
    elif play == "D":
        play = (34,15)
    elif play == "E":
        play = (34,-15)
    elif play == "F":
        play = (34,-45)
    elif play == "G":
        play = (64,15)
    elif play == "H":
        play = (64,-15)
    elif play == "I":
        play = (64,-45)
    elif play == "END":
        print " GAME FINISHES : Cross Wins!"
        i=0
        turtle.bye()
    turtle.goto(play)
    MakeCircle()
    return i

def PlayCircle():
    play=raw_input(" CIRCLE : Where do you want to play? : ")
    i=1
    if play == "A":
        play = (14,3)
    elif play == "B":
        play = (14,-27)
    elif play == "C":
        play = (14,-57)
    elif play == "D":
        play = (44,3)
    elif play == "E":
        play = (44,-23)
    elif play == "F":
        play = (44,-57)
    elif play == "G":
        play = (74,3)
    elif play == "H":
        play = (74,-27)
    elif play == "I":
        play = (74,-57)
    elif play == "END":
        print " GAME FINISHES : Cross Wins!"
        i=0
        turtle.bye()
    turtle.goto(play)
    MakeCircle()
    return i

def PlayCross():
    play=raw_input(" CROSS : Where do you want to play? : ")
    i=1
    if play == "A":
        play = (10,10)
    elif play == "B":
        play = (10,-20)
    elif play == "C":
        play = (10,-50)
    elif play == "D":
        play = (40,10)
    elif play == "E":
        play = (40,-20)
    elif play == "F":
        play = (40,-50)
    elif play == "G":
        play = (70,10)
    elif play == "H":
        play = (70,-20)
    elif play == "I":
        play = (70,-50)
    elif play == "END":
        print " GAME FINISHES : Circle Wins!"
        i=0
        turtle.bye()
    turtle.goto(play)
    MakeCross()
    return i

print "\n TIC - TAC - TOE "
print "\n The objective of the game is to complete a line of 3 circles(O) "
print " or crosses (X), before your opponent. (2 Player Game) "
print " Circle plays first. If a player has won, enter 'END' in input. "
print
print " Play according to this : "
print " A D G "
print " B E H "
print " C F I "

MakeTable()
PlayFirstCircle()
turtle.seth(0)
PlayCross()
turtle.seth(0)
PlayCircle()
turtle.seth(0)
PlayCross()
turtle.seth(0)
PlayCircle()
turtle.seth(0)
PlayCross()
turtle.seth(0)
PlayCircle()
turtle.seth(0)
PlayCross()
turtle.seth(0)
PlayCircle()
turtle.seth(0)