猫史档案馆


【Python作品分享】五子棋【求助帖】

用户:元白白元白白查看:74 回复:1 评论:1 创建时间:2024-03-13T22:24:26


【作品展示】

center_image

 

【作品介绍】

怎么做判断胜负啊QAQ

 

【作品源代码】

import turtle as t
import time as 喵
import pygame as py

#py.mixer.init()
#py.mixer.music.load('music.mp3')
#py.mixer.music.play()

t.speed(0)
t.delay(0)
t.bgcolor('tan')
t.setup(880, 880)

def image_Tb(x,y):
    t.up()
    t.goto(x,y)
    t.down()

t.color('black')
t.rt(90)
t.begin_poly()
t.fillcolor('tan')
t.begin_fill()
for i in range(4):
    t.fd(44)
    t.lt(90)
t.end_fill()
t.end_poly()

s = t.get_poly()
t.register_shape('zhx', s)
t.shape('zhx')
t.clear()

wc = 350
for i in range(18):
    wcnm = -354
    for i in range(18):
        image_Tb(wcnm,wc)
        t.stamp()
        wcnm += 44
    wc -= 44

wc = -395
for i in range(19):
    image_Tb(wc,-422)
    t.write(i, align="center", font=("楷体", 18, "normal"))
    wc += 43.5

wc = -410
for i in range(19):
    image_Tb(-415,wc)
    t.write(i, align="center", font=("楷体", 18, "normal"))
    wc += 43.5

t.hideturtle()
ls = [[0]*25 for i in range(25)]

hx1 = 0
hy1 = 0
bx1 = 0
by1 = 0

while True:
    while True:
        hx = int(t.textinput('黑','你要下在第几列?'))
        hy = int(t.textinput('黑','你要下在第几行?'))
        if ls[hx][hy] > 1:
            t.textinput('黑','——*^*——\n程序好像出了错误,请等待……')
            t.textinput('黑','Q^Q\n原来是你!不允许下在同一个位置哦!')
            continue
        else:
            hx1 = hx
            hy1 = hy
            hx = -400 + hx * 44
            hy = -400 + hy * 44
            image_Tb(hx, hy)
            t.color('black')
            t.dot(44)
            ls[hx1][hy1] = 2
            break

    喵.sleep(1)

    while True:
        bx = int(t.textinput('白', '你要下在第几列?'))
        by = int(t.textinput('白', '你要下在第几行?'))
        if ls[bx][by] > 1:
            t.textinput('白', '——*^*——\n程序好像出了错误,请等待……')
            t.textinput('白', 'Q^Q\n原来是你!不允许下在同一个位置哦!')
            continue
        else:
            bx1 = bx
            by1 = by
            bx = -400 + bx * 44
            by = -400 + by * 44
            image_Tb(bx,by)
            t.color('white')
            t.dot(44)
            ls[bx1][by1] = 3
            break

    喵.sleep(1)




t.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页第 1 页 / 共 1 页下一页
元白白元白白

有没有人帮我一下啊QAQ~

点赞1


评论

侦测行(t+1)[t+2]....[t+5] 或[t-1]....... 侦测列[m+1][m+2].....[m+5] 或[m-1]...... 侦测斜着的 [t+1][m+1]重复