vb.net小游戏代码 vb游戏代码大全( 五 )


Else
v = Search(NextCer(Cer), Steps - 1, False, -UpMax)''没有连续可吃子,继续搜索
End If
''恢复棋盘
ChessBoard(Sc(i).x1, Sc(i).y1) = b''恢复被吃子
ChessBoard(Sc(i).Initx, Sc(i).Inity) = b1 ''记录起点棋子和终点棋子
ChessBoard(Sc(i).ObjX, Sc(i).ObjY) = b2
'' 显示每种走法的得分
If IsTop Then
List1.AddItem "从"Str(Sc(i).Initx)","Str(Sc(i).Inity)_
"到"Str(Sc(i).ObjX)","Str(Sc(i).ObjY)"得分:"Str(v)
End If
'如果这种走法分数高,记录
If IsTop And (vMaxValue Or MaxValue = https://www.04ip.com/post/-30000) Then
BestLocate.Initx = Sc(i).Initx
BestLocate.Inity = Sc(i).Inity
BestLocate.ObjX = Sc(i).ObjX
BestLocate.ObjY = Sc(i).ObjY
BestLocate.x1 = Sc(i).x1
BestLocate.y1 = Sc(i).y1
MaxValue = https://www.04ip.com/post/v
End If
If vMaxValue Then MaxValue = https://www.04ip.com/post/v
'下句: 如果 MaxValue = https://www.04ip.com/post/-UpMax//α-β剪枝, 符合剪枝条件的就Cut掉 。UpMax为上层的MaxValue
If IsTop = False And MaxValue = https://www.04ip.com/post/-UpMax Then i = 100''剪枝程序
End If
Next i
If IsTop = False Then Search = -MaxValue Else Search = MaxValue
End Function
Private Sub cbText_Click(Index As Integer)
Dim i As Integer, j As Integer, C As Integer''C记载吃子
Dim Temp As String, Temp2 As String, Temp3 As String
Dim x As Byte, y As Byte, x2 As Byte, y2 As Byte
If cbText(Index).BackColorHC0E0FF Then Call MsgBox("落棋无效!", vbOKOnly + 32, "提示:"): Exit Sub
If cSel = 0 And Trim(cbText(Index).Text)"" Then cSel = Index: cbText(cSel).ForeColor = QBColor(12): Exit Sub ''如果玩家一个也没先且当前棋盘位置有棋子 , 则标示玩家选择此棋子
If cSel0 And Val(cbText(Index).Text) = Val(cbText(cSel).Text) Then cbText(cSel).ForeColor = H80000008: cSel = 0: Exit Sub ''如果玩家两次选择相同的棋子则取消选择
If cSel0 Then
''下棋
cbText(Index).Text = cbText(cSel).Text
''判断是否可变成加强棋
k = Val(cbText(Index).Text)
If Int(k / 100) = 1 And Index8 Then cbText(Index).Text = "102"''如果1方走到顶端就变成加强棋
If Int(k / 100) = 2 And Index55 Then cbText(Index).Text = "202"''如果2方走到顶端就变成加强棋
cbText(cSel).Text = ""
cbText(cSel).ForeColor = H80000008
''判断有没有吃子
''向上左斜
If Index - cSel = -18 Then
cbText(Index + 9).Text = "":''被吃子
C = Index + 9
End If
''向上右斜
If Index - cSel = -14 Then
cbText(Index + 7).Text = "":''被吃子
C = Index + 7
End If
''向下左斜
If Index - cSel = 14 Then
cbText(Index - 7).Text = "":''被吃子
C = Index - 7
End If
''向下右斜
If Index - cSel = 18 Then
cbText(Index - 9).Text = "":''被吃子
C = Index - 9
End If
''存储走法
k = 0: Temp = "": Temp2 = "": Temp = ""
For i = 1 To 8
For j = 1 To 8
If k = cSel Then Temp = "从"Str(i) + "," + Str(j)
If k = Index Then Temp2 = " 到" + Str(i) + "," + Str(j): x = i: y = j
If k = C Then Temp3 = "吃子 "Str(i)","Str(j): x2 = i: y2 = j
k = k + 1
Next j
Next i
List2.AddItem "第"Str(CurrentStep)"手 "Str(CurrentPlayer) + "方" + Temp + Temp2 + Temp3
CurrentStep = CurrentStep + 1
Text3.Text = Temp + Temp2
cSel = 0
Call ReDisplay
''下句:如果是人机模式并且玩家还没有可吃子
If 人机模式 = True And (IsLine(CurrentPlayer, x, y) = True And x21 And y22) = False Then
'If 人机模式 = True Then
''看玩家走了哪方的棋子 , 就运算另一方的棋子
CurrentPlayer = NextCer(Int(Val(cbText(Index).Text) / 100))
Call Command2_Click''如果是人机模式则让电脑运长

推荐阅读