五子棋

五子棋,第1张

概述五子棋

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

from graphics import *from math import *def gobangwin():    win=GraphWin("this is a gobang game",400,400) #ÖÆ×÷21x21µÄÆåÅÌ    win.setBackground("yellow")    i1=0        while i1<401:        l=line(Point(i1,0),Point(i1,400))        l.draw(win)        i1=i1+20    i2=0        while i2<401:        l=line(Point(0,i2),Point(400,i2))        l.draw(win)        i2=i2+20    return win    def main():    win = gobangwin()        List1 = []    List2 = []    List3 = []        change = 0    g = 0    m=0    n=0        while g == 0:       if change%2 == 1:        p1 = win.getMouse()        if not ((round((p1.getX()+10)/20),round((p1.getY()+10)/20)) in List3):                          a1 = round((p1.getX()+10)/20)             b1 = round((p1.getY()+10)/20)             List1.append((a1,b1))             List3.append((a1,b1))             pIEce = Circle(Point(20*a1,20*b1),8) #´´½¨Æå×Ó             pIEce.setFill('white')             pIEce.draw(win)             for m in range(21): #ÅжÏÊäÓ®                 for n in range(21):                                              if n<17 and (m,n) in List1 and (m,n+1) in List1 and (m,n+2) in List1 and (m,n+3) in List1 and (m,n+4) in List1 :                             message = Text(Point(100,100),"white win.")                             message.draw(win)                             g = 1     #Åжϰ×ÆåÊúÐÐ                         elif m<17 and  (m,n) in List1 and (m+1,n) in List1 and (m+2,n) in List1 and (m+3,n) in List1 and (m+4,n) in List1 :                             message = Text(Point(100,"white win.")                             message.draw(win)                             g = 1   #Åжϰ×ÆåºáÐÐ                         elif m<17 and n<17 and (m,n+1) in List1 and (m+2,n+2) in List1 and (m+3,n+3) in List1 and (m+4,"white win.")                             message.draw(win)                             g = 1    #Åжϰ×ÆåбÐÐ                         elif m<17 and n>3 and (m,n-1) in List1 and (m+2,n-2) in List1 and (m+3,n-3) in List1 and (m+4,n-4) in List1 :                             message = Text(Point(100,"white win.")                             message.draw(win)                             g = 1     #Åжϰ×ÆåбÐÐ                         else: change = change+1  #»»ºÚÆå×ß                   else:        p2 = win.getMouse()        if not ((round((p2.getX()+10)/20),round((p2.getY()+10)/20)) in List3):                             a2 = round((p2.getX()+10)/20)               b2 = round((p2.getY()+10)/20)               List2.append((a2,b2))               List3.append((a2,b2))                              pIEce = Circle(Point(20*a2,20*b2),8)               pIEce.setFill('black')               pIEce.draw(win)               for m in range(21):                 for n in range(21):                                              if n<17 and (m,n) in List2 and (m,n+1) in List2 and (m,n+2) in List2 and (m,n+3) in List2 and (m,n+4) in List2 :                             message = Text(Point(100,"black win.")                             message.draw(win)                             g = 1    #ÅжϺÚÆåÊúÐÐ                         elif m<17 and  (m,n) in List2 and (m+1,n) in List2 and (m+2,n) in List2 and (m+3,n) in List2 and (m+4,n) in List2 :                             message = Text(Point(100,"black win.")                             message.draw(win)                             g = 1  #ÅжϺÚÆåºáÐÐ                         elif m<17 and n<17 and (m,n+1) in List2 and (m+2,n+2) in List2 and (m+3,n+3) in List2 and (m+4,"black win.")                             message.draw(win)                             g = 1   #ÅжϺÚÆåбÐÐ                         elif m<17 and n>3 and (m,n-1) in List2 and (m+2,n-2) in List2 and (m+3,n-3) in List2 and (m+4,n-4) in List2 :                             message = Text(Point(100,"black win.")                             message.draw(win)                             g = 1   #ÅжϺÚÆåбÐÐ                         else: change = change+1  #»»°×Æå×ß                         message = Text(Point(100,120),"Click anywhere to quit.")    message.draw(win)    win.getMouse()    win.close()        main()                                       

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的五子棋全部内容,希望文章能够帮你解决五子棋所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1198642.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存