Dim x As Byte, y As Byte, x1 As Byte, y1 As Byte
Dim i As Integer, j As Integer
IsLine2 = False
''开始搜索棋盘
For i = 1 To 8
For j = 1 To 8
''如果是Cer方的棋子
If Int(ChessBoard(i, j) / 100) = Cer Then
''吃子式走法1:即如果基本走法的位置有对方的棋子则可以跳吃(走法限制:Cer为1或棋子为加强棋才可走)
If Int(ChessBoard(i - 1, j - 1) / 100) = NextCer(Cer) And (Cer = 1 Or ChessBoard(i, j) Mod 100 = 2) Then
x = (i - 1) - 1''目标坐标
y = (j - 1) - 1
x1 = i - 1''吃子坐标
y1 = j - 1
If x0 And y0 And x9 And y9 And ChessBoard(x, y) = 0 Then IsLine2 = True'有可吃子,返回True
End If
''吃子式走法2
If Int(ChessBoard(i - 1, j + 1) / 100) = NextCer(Cer) And (Cer = 1 Or ChessBoard(i, j) Mod 100 = 2) Then
x = (i - 1) - 1
y = (j + 1) + 1
x1 = i - 1
y1 = j + 1
If x0 And y0 And x9 And y9 And ChessBoard(x, y) = 0 Then IsLine2 = True'有可吃子,返回True
End If
''吃子式走法3
If Int(ChessBoard(i + 1, j - 1) / 100) = NextCer(Cer) And (Cer = 2 Or ChessBoard(i, j) Mod 100 = 2) Then
x = (i + 1) + 1
【vb.net小游戏代码 vb游戏代码大全】y = (j - 1) - 1
x1 = i + 1
y1 = j - 1
If x0 And y0 And x9 And y9 And ChessBoard(x, y) = 0 Then IsLine2 = True'有可吃子,返回True
End If
''吃子式走法4
If Int(ChessBoard(i + 1, j + 1) / 100) = NextCer(Cer) And (Cer = 2 Or ChessBoard(i, j) Mod 100 = 2) Then
x = (i + 1) + 1
y = (j + 1) + 1
x1 = i + 1
y1 = j + 1
If x0 And y0 And x9 And y9 And ChessBoard(x, y) = 0 Then IsLine2 = True'有可吃子,返回True
End If
End If
Next j
Next i
End Function
Rem 搜索程序
Private Function Search(Cer As Byte, Steps As Integer, IsTop As Boolean, UpMax As Integer)
Dim a As Integer, b As Integer, b1 As Integer, b2 As Integer, i As Integer, j As Integer, k As Integer, l As Integer, v As Integer
Dim MaxValue As Integer
Dim Sc(40) As CHESSER
Dim IsEat(7) As Boolean''搜索到的7种走法有没有吃子
Dim EAT As Boolean''有没有吃子
If IsTop Then
List1.Clear
For i = 0 To 40: Sc(i).Allow = False: Next i ';默认情况下所有走法皆不允许,如果所有值均为False则皆允许
End If
EAT = False
For i = 0 To 7: IsEat(7) = False: Next i''默认情况所有搜索到的走法都没有吃子
Steps = Steps - 1
If Steps1 And IsLine2(Cer) = False Then
''如果我方无子可吃时才返回估值
Search = -CurrentValue(Cer)''返回估值
Exit Function
End If
k = 0
''开始搜索棋盘
For i = 1 To 8
For j = 1 To 8
''如果是Cer方的棋子
If Int(ChessBoard(i, j) / 100) = Cer Then
For i1 = 1 To MAXDOWNPOINT: x(i1) = 0: x1(i1) = 0: Next ''x记载所有走法 , 清空x
''列出所有走法
''基本走法:上左、上右、下左、下右
x(0) = i - 1: y(0) = j - 1
x(1) = i - 1: y(1) = j + 1
x(2) = i + 1: y(2) = j - 1
x(3) = i + 1: y(3) = j + 1
''棋子表示方法:白棋101(普通)、102 (过底的威力棋)
''红棋201(普通)、202 (过底的威力棋)
''下一句解释:如果是白棋(101、102),不允许后退(删除x(2)、x(3))
If Cer = 1 And ChessBoard(i, j) Mod 1002 Then x(2) = -2: x(3) = -2
''下一句解释:如果是红棋(201、202),不允许后退(删除x(0)、x(1))
If Cer = 2 And ChessBoard(i, j) Mod 1002 Then x(0) = -2: x(1) = -2
''吃子式走法1:即如果基本走法的位置有对方的棋子则可以跳吃(走法限制:Cer为1或棋子为加强棋才可走)
If Int(ChessBoard(i - 1, j - 1) / 100) = NextCer(Cer) And (Cer = 1 Or ChessBoard(i, j) Mod 100 = 2) Then
x(4) = (i - 1) - 1''目标坐标
- 如何获取云服务器的源代码? 云服务器源代码怎么弄
- 如何设置云服务器的源代码? 云服务器源代码怎么设置
- 如何修改云服务器的源代码? 云服务器源码怎么修改
- 如何寻找云服务器的源代码? 云服务器源码怎么找
- 如何配置云服务器的源代码? 云服务器源码怎么设置
- redis哨兵keepalive 代码redis哨兵
- redis怎么写 redis打字代码
- mongodb开发 mongodb是开放源代码吗
- mysql生成器 mysql代码生成er图
- redis编程 redis代码案例
