C#实现五子棋人机及局域网


使用C#Winform实现五子棋人机及局域网功能,二维数组画棋盘。
资源截图
代码片段和文件信息
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fivestones
{

    class Chessboard
    {
        //arrchessboard为棋盘情况数组,arrchessboard[ij]=2表示此处无子,arrchessboard[ij]=0表示此处为黑子,arrchessboard[ij]=1表示此处为白子
        public int[] arrchessboard = new int[15 15];
        //绘制的对象
        public Graphics mg;
        //棋子对象
        public Stone stone;
        ////电脑对象
        private Computer computer;
        //判断当前棋子是黑(true)是白(false)
        public bool stoneflag = true;
        //判断先手玩家(是电脑(true)还是人(false),先手下黑棋)
        private bool mplayfirstflag = false;
        //历史记录堆栈
        private Stack mStarckHistory = new Stack();
        public bool a = true;//判断只有点击开始时才可进行落子
        //Form2 form2 = new Form2();

        public Chessboard(Graphics g)
        {

            Initialization();
            mg = g;
        }

        /// 
        /// 画棋盘
        /// 

        public void Draw()
        {

            Image img = Properties.Resources.chessboard; //获取棋盘图片 大小600*600像素
            mg.DrawImage(img 0 0 img.Width img.Height);
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    if (arrchessboard[i j] == 0)
                    {
                        stone.DrawStone(i j true);
                    }
                    if (arrchessboard[i j] == 1)
                    {
                        stone.DrawStone(i j false);
                    }
                }
            }
        }
        public void DownStone(int m int n)
        {
            stone.DrawStone(m n stoneflag);
            //记录情况
            if (stoneflag)
            {
                arrchessboard[m n] = 0;
            }
            else
            {
                arrchessboard[m n] = 1;
            }

            //判断结果

            if (rules.Result(m n arrchessboard) < 6)
            {
                switch (rules.Result(m n arrchessboard))
                {
                    case 1:
                        MessageBox.Show(“黑棋双三禁手失败!“);
                        a = false;
                        break;
                    case 2:
                        MessageBox.Show(“黑棋双四禁手失败!“);
                        a = false;
                        break;
                    case 3:
                        MessageBox.Show(“黑棋长连禁手失败!“);

                        break;

                    case 4:
                        if (stoneflag)
                        {
                            MessageBox.Show(“黑棋胜利!“);
                        }
                        else
                        {
                            MessageBox.Show(“白棋胜利!“);
                        }
                        break;
          

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1340  2018-04-16 15:23  FivestonesFivestonesPropertiesAssemblyInfo.cs

     文件        249  2018-04-16 15:23  FivestonesFivestonesPropertiesSettings.settings

     文件       1097  2018-04-16 15:23  FivestonesFivestonesPropertiesSettings.Designer.cs

     文件       6707  2018-04-16 18:31  FivestonesFivestonesPropertiesResources.resx

     文件       3994  2018-04-16 18:31  FivestonesFivestonesPropertiesResources.Designer.cs

     文件       1682  2018-04-16 15:24  FivestonesFivestonesPropertieswhitestone.gif

     文件       1723  2018-04-16 15:24  FivestonesFivestonesPropertieslackstone.gif

     文件     161859  2018-04-16 15:24  FivestonesFivestonesPropertieschessboard.gif

     文件        187  2018-04-16 15:23  FivestonesFivestonesApp.config

     文件       2036  2018-05-29 11:52  FivestonesFivestonesForm1.cs

     文件       3486  2018-05-16 18:09  FivestonesFivestonesForm1.Designer.cs

     文件        523  2018-06-06 13:58  FivestonesFivestonesProgram.cs

     文件       7854  2018-06-06 13:56  FivestonesFivestonesFivestones.csproj

     文件       5817  2018-05-16 18:09  FivestonesFivestonesForm1.resx

     文件       6487  2018-05-31 20:23  FivestonesFivestoneschessboard.cs

     文件       1692  2018-06-05 21:50  FivestonesFivestonesStone.cs

     文件       1723  2018-04-16 15:24  FivestonesFivestoneslackstone.gif

     文件     161859  2018-04-16 15:24  FivestonesFivestoneschessboard.gif

     文件       1682  2018-04-16 15:24  FivestonesFivestoneswhitestone.gif

     文件       1723  2018-04-16 18:30  FivestonesFivestonesResourceslackstone.gif

     文件     161859  2018-04-16 18:30  FivestonesFivestonesResourceschessboard.gif

     文件       1682  2018-04-16 18:30  FivestonesFivestonesResourceswhitestone.gif

     文件      13441  2018-05-22 14:40  FivestonesFivestones
ules.cs

     文件      14918  2018-06-06 12:21  FivestonesFivestonesForm2.cs

     文件       4487  2018-05-28 11:32  FivestonesFivestonesForm2.Designer.cs

     文件       5817  2018-05-16 17:33  FivestonesFivestonesForm2.resx

     文件        641  2018-04-25 05:08  FivestonesFivestonesFivestones.csproj.user

     文件       1488  2018-05-23 16:47  FivestonesFivestonescreatroom.cs

     文件       6227  2018-05-10 22:05  FivestonesFivestonescreatroom.Designer.cs

     文件       5817  2018-05-10 22:05  FivestonesFivestonescreatroom.resx

............此处省略126个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)