打印本文 打印本文 关闭窗口 关闭窗口
使用vb.net实现五子棋的人工智能3
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1794  更新时间:2009/4/23 19:01:34  文章录入:mintao  责任编辑:mintao

                                                 五子棋的人工智能

                                                          ———— 利用策略类AI和vb.net实现五子棋

                                                                                    作者:张宇

    四,处理鼠标事件

    ''''*****************************************************************************

    ''''** 模块名称:  themousedown

    ''''**

    ''''** 描述:       此函数主要实行以下功能:

    ''''**                 1. 判定当前游戏标志是否有效。

    ''''**                 2. 将实际坐标转化成虚拟坐标。

    ''''**                 3. 绘制玩家的棋子。

    ''''**                 4. 执行检查获胜函数。

    ''''**                 5. 执行电脑算法函数。

    ''''**

    ''''*****************************************************************************

    Sub themousedown(ByVal x As Integer, ByVal y As Integer)

        If theplayflag = False Then

            Exit Sub

        End If

        ''''检查游戏状态是否有效

        Dim i, j As Integer

        Dim zhx, zhy As Integer

        zhx = Int((x - 10) / 30)

        zhy = Int((y - 10) / 30)

        For i = 0 To 9

            For j = 0 To 9

                If table(zhx, zhy) > 0 Then

                    Exit Sub

                End If

            Next

        Next

        ''''检查当前鼠标点击的格子是否有效

        Dim mycolor As Color

        Dim g As System.Drawing.Graphics

        g = PictureBox1.CreateGraphics

        mycolor = Color.White

        Dim brush1 As System.Drawing.Brush = New SolidBrush(mycolor)

        g.FillEllipse(brush1, zhx * 30 + 10, zhy * 30 + 10, 30, 30)

        ''''绘制玩家的棋子

        table(zhx, zhy) = 2

        For i = 0 To 191

            If cwin(zhx, zhy, i) = True Then

 

[1] [2] [3]  下一页

打印本文 打印本文 关闭窗口 关闭窗口