如何在代码中修复移动取景器和获胜条件

时间:2019-06-29 21:46:23

标签: python-3.x

我正在尝试对火柴盒计算机进行硬编码来制作六卒,而移动查找系统和获胜条件也出现了问题。我应该如何解决这个问题?

我试图输入一些调试值,但是我无法将问题追溯到任何地方。

这是代码段,但完整的python could be found here

elif a == 0:
    if rows[r-1][a+1] == 'A' or rows[r-1][a+1] == 'B' or rows[r-1][a+1] == 'C':
        if move1 == ['','',0,0,0,0,0]:
            move1 = ['a','up-right',r,a,r-1,a+1,1]
        elif move2 == ['','',0,0,0,0,0]:
            move2 = ['a','up-right',r,a,r-1,a+1,1]
        elif move3 == ['','',0,0,0,0,0]:
            move3 = ['a','up-right',r,a,r-1,a+1,1]
        elif move4 == ['','',0,0,0,0,0]:
            move4 = ['a','up-right',r,a,r-1,a+1,1]
    if rows[r-1][a] == 'X':
        if move1 == ['','',0,0,0,0,0]:
            move1 = ['a','up',r,a,r-1,a,0]
        elif move2 == ['','',0,0,0,0,0]:
            move2 = ['a','up',r,a,r-1,a,0]
        elif move3 == ['','',0,0,0,0,0]:
            move3 = ['a','up',r,a,r-1,a,0]
        elif move4 == ['','',0,0,0,0,0]:
            move4 = ['a','up',r,a,r-1,a,0]
elif a == 1:
    if rows[r-1][a+1] == 'A' or rows[r-1][a+1] == 'B' or rows[r-1][a+1] == 'C':
        if move1 == ['','',0,0,0,0,0]:
            move1 = ['a','up-right',r,a,r-1,a+1,1]
        elif move2 == ['','',0,0,0,0,0]:
            move2 = ['a','up-right',r,a,r-1,a+1,1]
        elif move3 == ['','',0,0,0,0,0]:
            move3 = ['a','up-right',r,a,r-1,a+1,1]
        elif move4 == ['','',0,0,0,0,0]:
            move4 = ['a','up-right',r,a,r-1,a+1,1]
    if rows[r-1][a-1] == 'A' or rows[r-1][a-1] == 'B' or rows[r-1][a-1] == 'C':
        if move1 == ['','',0,0,0,0,0]:
            move1 = ['a','up-left',r,a,r-1,a-1,1]
        elif move2 == ['','',0,0,0,0,0]:
            move2 = ['a','up-left',r,a,r-1,a-1,1]
        elif move3 == ['','',0,0,0,0,0]:
            move3 = ['a','up-left',r,a,r-1,a-1,1]
        elif move4 == ['','',0,0,0,0,0]:
            move4 = ['a','up-left',r,a,r-1,a-1,1]
    if rows[r-1][a] == 'X':
        if move1 == ['','',0,0,0,0,0]:
            move1 = ['a','up',r,a,r-1,a,0]
        elif move2 == ['','',0,0,0,0,0]:
            move2 = ['a','up',r,a,r-1,a,0]
        elif move3 == ['','',0,0,0,0,0]:
            move3 = ['a','up',r,a,r-1,a,0]
        elif move4 == ['','',0,0,0,0,0]:
            move4 = ['a','up',r,a,r-1,a,0]

例如,在游戏的第一步中,我希望可能有2步,因为第三步可能会有错误,但是无论如何它都会添加它,并且在大多数游戏中都会持续存在

同样,有时也不会考虑可能的移动,例如,如果您的一块a位于底部第二行,则不会考虑所有带有捕获的移动。

最后,程序会说AI赢了。

任何帮助将不胜感激。

好的,

ReedsShorts

0 个答案:

没有答案