发信人: hunter__fox(雁回西楼)
整理人: winsy(2003-01-18 21:01:35), 站内信件
|
'指定的棋是否胜出
'Index 为对应的棋子标志(Def_Black或Def_White)
'返回值为真则为此胜出
Function IsVictery(Index As Byte) As Boolean
Dim n As Integer, m As Integer, pix(0 To 1) As Byte
'X方向和Y方向
Debug.Assert C_Debug
For n = 1 To Lines
pix(0) = 0: pix(1) = 0
For m = 1 To Lines
pix(0) = IIf(aQiZi(n, m) = Index, pix(0) + 1, 0)
pix(1) = IIf(aQiZi(m, n) = Index, pix(1) + 1, 0)
If (pix(0) = 5) Or (pix(1) = 5) Then
IsVictery = True
Exit Function
End If
Next m
Next n
'左斜
Debug.Assert C_Debug
For n = 0 To Lines
pix(0) = 0: pix(1) = 0
For m = 1 To Lines - n
pix(0) = IIf(aQiZi(n + m, m) = Index, pix(0) + 1, 0)
pix(1) = IIf(aQiZi(m, n + m) = Index, pix(1) + 1, 0)
If (pix(0) = 5) Or (pix(1) = 5) Then
IsVictery = True
Exit Function
End If
Next m
Next n
'右斜
Debug.Assert C_Debug
For n = 1 To Lines
pix(0) = 0
For m = 1 To n
pix(0) = IIf(aQiZi(m, n - m + 1) = Index, pix(0) + 1, 0)
pix(1) = IIf(aQiZi(Lines - n + m, Lines - m + 1) = Index, pix(1) + 1, 0)
If (pix(0) = 5) Or (pix(1) = 5) Then
IsVictery = True
Exit Function
End If
Next m
Next n
End Function
---- 作者:hunter__fox【雁回西楼】
※ 来源: 网易虚拟社区 广州站.
※ 个人天地 流水情怀[ccbyy] 灌水精英 NO:003
※ 编程开发 VFP[VFP] |
|