⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbcch.frm

📁 VB版的中国象棋人机对战源程序
💻 FRM
📖 第 1 页 / 共 5 页
字号:
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   21
      Left            =   2760
      TabIndex        =   68
      Top             =   1800
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   20
      Left            =   1875
      TabIndex        =   69
      Top             =   1800
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   19
      Left            =   960
      TabIndex        =   70
      Top             =   1800
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   18
      Left            =   120
      TabIndex        =   71
      Top             =   1800
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   17
      Left            =   7080
      TabIndex        =   72
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   16
      Left            =   6195
      TabIndex        =   73
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   15
      Left            =   5295
      TabIndex        =   74
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   14
      Left            =   4455
      TabIndex        =   75
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   13
      Left            =   3600
      TabIndex        =   76
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   12
      Left            =   2760
      TabIndex        =   77
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   11
      Left            =   1875
      TabIndex        =   78
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   10
      Left            =   960
      TabIndex        =   79
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   9
      Left            =   120
      TabIndex        =   80
      Top             =   1020
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   8
      Left            =   7080
      TabIndex        =   81
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   7
      Left            =   6200
      TabIndex        =   82
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   6
      Left            =   5300
      TabIndex        =   83
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   5
      Left            =   4460
      TabIndex        =   84
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   4
      Left            =   3600
      TabIndex        =   85
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   3
      Left            =   2760
      TabIndex        =   86
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   2
      Left            =   1880
      TabIndex        =   87
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   1
      Left            =   960
      TabIndex        =   88
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin 工程1.Cchess Cchess1 
      Height          =   765
      Index           =   0
      Left            =   120
      TabIndex        =   89
      Top             =   240
      Width           =   765
      _ExtentX        =   0
      _ExtentY        =   0
   End
   Begin VB.Label Label2 
      Caption         =   "分数"
      Height          =   375
      Index           =   1
      Left            =   7920
      TabIndex        =   97
      Top             =   4560
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "层数"
      Height          =   375
      Index           =   0
      Left            =   7920
      TabIndex        =   96
      Top             =   4080
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   375
      Left            =   7920
      TabIndex        =   93
      Top             =   6360
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.Image Image1 
      Height          =   7560
      Left            =   240
      Picture         =   "VbCch.frx":0000
      Top             =   360
      Width           =   7470
   End
End
Attribute VB_Name = "VbCch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Rem 横9竖10
Rem 各棋代码:
Rem 将107、士106、象105、车104、马103、包102、卒101(黑)
Rem 帅207、仕206、相205、车204、马203、炮202、兵201(红)
Rem 象棋浏程图

Dim C As Byte       ''当前玩家
Dim cSel As Byte, osel As Byte       ''当前选中哪个棋子,目标哪个棋子
Dim DoCchess As Boolean              ''是否允许玩家选中棋子
Public a As Byte, b As Byte

Dim PubBestLocate As CHESSER           ''最后运算分数最高的结果

Const INITVALUE = -10000             ''初始分数
Const KING = 5000

Dim ChessBoard(9, 10) As Chess            ''棋盘(横9列,竖10行)
Dim ChessBoardCopy(9, 10) As Chess         ''棋盘的复本


    


Public Function Max(a As Variant, b As Variant)
    
    If a > b Then Max = a Else Max = b
    
End Function

Rem 返回Cer方与落棋点的棋子的得分
Public Function CchessValue(ByVal Cer As Byte, ByVal Cchess) As Integer
    
    Select Case (Cchess Mod 100)
        
        Case 7:
            ''将
            CchessValue = KING
        
        Case 6:
            ''士
            CchessValue = 7
            
        Case 5:
            ''象
            CchessValue = 7
            
        Case 4:
            ''车
            CchessValue = 50
            
        Case 3:
            ''马
            CchessValue = 25
            
        Case 2:
            ''炮
            CchessValue = 20
            
        Case 1:
            ''卒
            CchessValue = 5
        
    End Select
    
    If Cer = 0 Then Exit Function    ''0表示仅返回棋子值,不判断为哪一方的棋子
    
    If Int(Cchess / 100) <> Cer Then CchessValue = 0 - CchessValue    ''如果棋子不是Cer方的,则返回负值
    
End Function


Rem 计算Cer方的得分
Public Function Win_Lost(Cer As Byte) As Integer
    
    Dim i As Byte, j As Byte, k As Integer
    
   
    Win_Lost = 0
    
    For i = 1 To 9
        
        For j = 1 To 10
            
            ''Cer方的局面价值
            k = CchessValue(Cer, ChessBoard(i, j).Value)    ''k为棋盘i,j位置的棋子,如果是我方的棋子则加分,否则减分
            
            
            Win_Lost = Win_Lost + k

        Next j
    
    Next i
    
End Function

Rem 如果是自己的棋则


Rem 根据当前棋返回棋面文字
Public Function CchessWord(ByVal Cchess As Byte) As String
    
    Select Case Cchess
        
        Case 107:
            CchessWord = "将"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -