苦思冥想了两天两夜了,看不出来哪里错了!请大侠帮忙啦,跪谢!
Private Sub FenZu()
Dim a As Integer, b As Integer
a = PosX(NowStep) 'nowstep 是当前落子的手数,posx(20),posy(20) 两个一维数组记录的是它的坐标,模块级定义过
b = PosY(NowStep)
Static g As Integer
g = g + 1
Zu(a, b) = g
Exit Sub
If xyExist(a - 1, b) = true And (No(a - 1, b) Mod 2) = (NowStep Mod 2) Then '棋子左边棋子并且同色
Zu(a, b) = Zu(a - 1, b) '令组号=相邻的组组号,一个组是一个棋串。用于以后计算气和提子。
'问题出在上面这句和后面一个if块相同位置。我用textbox检验了条件都满足.左边的有棋子,而且颜色相同了,
’可是左边的是第1 组,右边的新下的棋子还是2 组。
End If
If xyExist(a + 1, b) = true And (No(a + 1, b) Mod 2) = (NowStep Mod 2) Then ’判断右边的
For i = 1 To NowStep
If Zu(PosX(i), PosY(i)) = Zu(a, b) Then Zu(PosX(i), PosY(i)) = Zu(a + 1, b) '把当前落子所在组所有棋子,
‘都并入相邻组
Next i
End If
If xyExist(a, b - 1) = true And (No(a, b - 1) Mod 2) = (NowStep Mod 2) Then
For i = 1 To NowStep
If Zu(PosX(i), PosY(i)) = Zu(a, b) Then Zu(PosX(i), PosY(i)) = Zu(a, b - 1)
Next i
End If
If xyExist(a, b + 1) = true And (No(a, b + 1) Mod 2) = (NowStep Mod 2) Then
For i = 1 To NowStep
If Zu(PosX(i), PosY(i)) = Zu(a, b) Then Zu(PosX(i), PosY(i)) = Zu(a, b + 1)
Next i
End If
If (No(a - 1, b) Mod 2) = (NowStep Mod 2) Or (No(a + 1, b) Mod 2) = (NowStep Mod 2) Then
g = g - 1
ElseIf (No(a, b - 1) Mod 2) = (NowStep Mod 2) Or (No(a, b + 1) Mod 2) = (NowStep Mod 2) Then
g = g - 1
End If
其中,xyExist(20,20)、Zu(20,20)、nowstep、 No(x,y)是模块级变量,之前都定义过。xyExist(20,20) 判断该位置是否有棋子。没有运行中错误信息,只是运行结果不正确。没有赋值