界面设计: 运行界面: 代码如下: Option Explicit Const SubWidth = 400 '定义画五子棋表格的每格长度和宽度 Private P2PlayColor As Integer '实现黑白棋子的交替进行 Private MyColor As Integer '标记黑白双方棋子颜色 Private IfSucceed As Boolean '表示是否胜利 Const pi = 3.14159 '定义字符常量pi=3.14159 Private centerx As Single Private centery As Single Private radius As Single Private DataArray(14, 14) As Integer '保存棋盘中棋子的位置信息(空子=3 黑棋=1 白棋=0) Private sumtime As Integer '记录总时间来判断谁超时 Private ifStarteasy As Boolean '标记简单难度下计时功能是否可以开启 (ifStarteasy=true 时 每落子一次计时开启一次) Private ifStartnormal As Boolean '标记中等难度下计时功能是否可以开启 (ifStartnormal=true 时 每落子一次计时开启一次) Private ifStarthard As Boolean '标记困难难度下计时功能是否可以开启 (ifStarthard=true 时 每落子一次计时开启一次) '单击命令按钮"退出"退出 Private Sub CmdExit_Click() End End Sub Private Sub CmdStart_Click() Dim i As Integer Dim m As Integer Dim n As Integer '绘制棋盘 PicQiPan.Cls PicQiPan.ForeColor = vbBlack For i = 1 To 14 PicQiPan.Line (SubWidth, SubWidth * i)-(SubWidth * 14, _ SubWidth * i) PicQiPan.Line (SubWidth * i, SubWidth)-(SubWidth * i, _ SubWidth * 14) Next i '棋盘落点信息初始化 For m = 0 To 14 For n = 0 To 14 DataArray(m, n) = 3 Next n Next m '主要标记信息初始化 P2PlayColor = 0 MyColor = 0 IfSucceed = False ifStarteasy = False ifStartnormal = False ifStarthard = False Timer2.Enabled = False Timer3.Enabled = False Timer4.Enabled = False FrmMain.Cls sumtime = -1 End Sub '简单难度 Private Sub fileeasy_Click() ifStarteasy = True sumtime = -1 MsgBox "双方下每步棋的思考时间最多 20 秒,否则超时清盘" End Sub '通过文件"退出"退出 Private Sub fileexit_Click() End End Sub '困难难度 Private Sub filehard_Click() ifStarthard =...