基于C#的五子棋游戏设计

article/2025/9/20 16:12:18

目 录
一、 毕业设计内容 3
二、 毕业设计目的 3
三、 工具/准备工作 3
四、 设计步骤和方法 3
(一) 总体设计 3
1. 总体设计思路及设计图 3
2. 界面设计 4
3. 全局变量设计 4
(二) 详细设计 5
1. 刷新棋盘 5
2. 绘制棋盘 5
3. 分步计时 5
4. 显示光标 6
5. 判断胜负 8
6. 判断禁手 10
7. 电脑落子 15
8. 玩家落子 18
9. 开始游戏 19
10. 退出游戏 20
11. 重新开局 20
12. 玩家认输 21
13. 玩家悔棋 22
(三) 测试 23
1. 判断胜负模块测试 23
2. 判断禁手模块测试 23
五、 心得体会 24
一、毕业设计内容
在Visual Studio 2015 平台上,开发一个“五子棋游戏”的Windows Form应用程序,题目要求:
1.整体规划,即画出棋盘和显示出“游戏开始”、“悔棋”、“退出游戏”等按钮。
2.游戏界面的具体实现,即有绝对坐标与相对坐标、又有界面的颜色与大小和各部分所处的位置。
3.在鼠标在棋盘上经过的时候,可以看出光标在那里;
4.正常落棋子,不会覆盖已有棋子。
5.记录游戏中棋子的落子过程,并且允许悔棋
6.判断双方输赢,先走出五子连珠的一方赢
7.先下者落子时不允许走禁手。
二、毕业设计目的
综合运用c#.net知识,在vs 2015 平台上,进行控制台应用程序和简单Windows Form应用程序的开发;本文转载自http://www.biyezuopin.vip/onews.asp?id=15126初步熟悉开发一个Windows软件的流程。
三、工具/准备工作
Microsoft Visual Studio 2015,PC机一台,上网查找资料,相关参考书籍。
四、设计步骤和方法
(一)总体设计
1.总体设计思路及设计图
(1)设计思路
① 充分了解五子棋游戏的一般规则,了解三三禁手、四四禁手和长连禁手的判定条件,以及黑白方如何落子、如何计时;
② 结合游戏规则设计简洁美观的游戏界面,使用相关控件,注意控件之间的联系;
③ 搜集资料,了解控件有关的函数及使用方法,完善程序逻辑;
④ 根据拟定好的程序逻辑,定义相关的全局变量和自定义函数;
⑤ 模拟多种情况调试程序,找出隐藏的错误,完善程序;
⑥ 整合逻辑及相关程序,完成毕业设计报告。

namespace Game4873
{partial class Form1{/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// 清理所有正在使用的资源。/// </summary>/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// <summary>/// 设计器支持所需的方法 - 不要修改/// 使用代码编辑器修改此方法的内容。/// </summary>private void InitializeComponent(){this.components = new System.ComponentModel.Container();this.groupBox1 = new System.Windows.Forms.GroupBox();this.radioButton2 = new System.Windows.Forms.RadioButton();this.radioButton1 = new System.Windows.Forms.RadioButton();this.groupBox2 = new System.Windows.Forms.GroupBox();this.button5 = new System.Windows.Forms.Button();this.button4 = new System.Windows.Forms.Button();this.button2 = new System.Windows.Forms.Button();this.button3 = new System.Windows.Forms.Button();this.button1 = new System.Windows.Forms.Button();this.splitContainer1 = new System.Windows.Forms.SplitContainer();this.panel1 = new System.Windows.Forms.Panel();this.label2 = new System.Windows.Forms.Label();this.label1 = new System.Windows.Forms.Label();this.textBox2 = new System.Windows.Forms.TextBox();this.textBox1 = new System.Windows.Forms.TextBox();this.panel2 = new System.Windows.Forms.Panel();this.timer1 = new System.Windows.Forms.Timer(this.components);this.groupBox1.SuspendLayout();this.groupBox2.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();this.splitContainer1.Panel1.SuspendLayout();this.splitContainer1.Panel2.SuspendLayout();this.splitContainer1.SuspendLayout();this.panel1.SuspendLayout();this.SuspendLayout();// // groupBox1// this.groupBox1.Controls.Add(this.radioButton2);this.groupBox1.Controls.Add(this.radioButton1);this.groupBox1.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.groupBox1.ForeColor = System.Drawing.SystemColors.ControlText;this.groupBox1.Location = new System.Drawing.Point(30, 14);this.groupBox1.Name = "groupBox1";this.groupBox1.Size = new System.Drawing.Size(105, 132);this.groupBox1.TabIndex = 0;this.groupBox1.TabStop = false;this.groupBox1.Text = "下棋顺序";// // radioButton2// this.radioButton2.AutoSize = true;this.radioButton2.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.radioButton2.ForeColor = System.Drawing.SystemColors.ControlText;this.radioButton2.Location = new System.Drawing.Point(6, 82);this.radioButton2.Name = "radioButton2";this.radioButton2.Size = new System.Drawing.Size(90, 20);this.radioButton2.TabIndex = 1;this.radioButton2.Text = "电脑先手";this.radioButton2.UseVisualStyleBackColor = true;// // radioButton1// this.radioButton1.AutoSize = true;this.radioButton1.Checked = true;this.radioButton1.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.radioButton1.ForeColor = System.Drawing.SystemColors.ControlText;this.radioButton1.Location = new System.Drawing.Point(7, 44);this.radioButton1.Name = "radioButton1";this.radioButton1.Size = new System.Drawing.Size(90, 20);this.radioButton1.TabIndex = 0;this.radioButton1.TabStop = true;this.radioButton1.Text = "玩家先手";this.radioButton1.UseVisualStyleBackColor = true;// // groupBox2// this.groupBox2.Controls.Add(this.button5);this.groupBox2.Controls.Add(this.button4);this.groupBox2.Controls.Add(this.button2);this.groupBox2.Controls.Add(this.button3);this.groupBox2.Controls.Add(this.button1);this.groupBox2.Font = new System.Drawing.Font("楷体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.groupBox2.ForeColor = System.Drawing.SystemColors.ControlText;this.groupBox2.Location = new System.Drawing.Point(162, 14);this.groupBox2.Name = "groupBox2";this.groupBox2.Size = new System.Drawing.Size(293, 132);this.groupBox2.TabIndex = 1;this.groupBox2.TabStop = false;this.groupBox2.Text = "游戏开关";// // button5// this.button5.BackColor = System.Drawing.SystemColors.ActiveCaption;this.button5.Enabled = false;this.button5.ForeColor = System.Drawing.SystemColors.ControlText;this.button5.Location = new System.Drawing.Point(115, 82);this.button5.Name = "button5";this.button5.Size = new System.Drawing.Size(65, 28);this.button5.TabIndex = 4;this.button5.Text = "悔棋";this.button5.UseVisualStyleBackColor = false;this.button5.Click += new System.EventHandler(this.button5_Click);// // button4// this.button4.BackColor = System.Drawing.SystemColors.ActiveCaption;this.button4.Enabled = false;this.button4.ForeColor = System.Drawing.SystemColors.ControlText;this.button4.Location = new System.Drawing.Point(202, 82);this.button4.Name = "button4";this.button4.Size = new System.Drawing.Size(65, 28);this.button4.TabIndex = 3;this.button4.Text = "认输";this.button4.UseVisualStyleBackColor = false;this.button4.Click += new System.EventHandler(this.button4_Click);// // button2// this.button2.BackColor = System.Drawing.SystemColors.ActiveCaption;this.button2.ForeColor = System.Drawing.SystemColors.ControlText;this.button2.Location = new System.Drawing.Point(169, 39);this.button2.Name = "button2";this.button2.Size = new System.Drawing.Size(65, 28);this.button2.TabIndex = 2;this.button2.Text = "退出";this.button2.UseVisualStyleBackColor = false;this.button2.Click += new System.EventHandler(this.button2_Click);// // button3// this.button3.BackColor = System.Drawing.SystemColors.ActiveCaption;this.button3.Enabled = false;this.button3.ForeColor = System.Drawing.SystemColors.ControlText;this.button3.Location = new System.Drawing.Point(30, 82);this.button3.Name = "button3";this.button3.Size = new System.Drawing.Size(65, 28);this.button3.TabIndex = 1;this.button3.Text = "重开";this.button3.UseVisualStyleBackColor = false;this.button3.Click += new System.EventHandler(this.button3_Click);// // button1// this.button1.BackColor = System.Drawing.SystemColors.ActiveCaption;this.button1.ForeColor = System.Drawing.SystemColors.ControlText;this.button1.Location = new System.Drawing.Point(62, 39);this.button1.Name = "button1";this.button1.Size = new System.Drawing.Size(65, 28);this.button1.TabIndex = 0;this.button1.Text = "开始";this.button1.UseVisualStyleBackColor = false;this.button1.Click += new System.EventHandler(this.button1_Click);// // splitContainer1// this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;this.splitContainer1.IsSplitterFixed = true;this.splitContainer1.Location = new System.Drawing.Point(0, 0);this.splitContainer1.Name = "splitContainer1";this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;// // splitContainer1.Panel1// this.splitContainer1.Panel1.Controls.Add(this.panel1);// // splitContainer1.Panel2// this.splitContainer1.Panel2.Controls.Add(this.panel2);this.splitContainer1.Size = new System.Drawing.Size(484, 687);this.splitContainer1.SplitterDistance = 191;this.splitContainer1.TabIndex = 3;// // panel1// this.panel1.Controls.Add(this.label2);this.panel1.Controls.Add(this.label1);this.panel1.Controls.Add(this.groupBox1);this.panel1.Controls.Add(this.textBox2);this.panel1.Controls.Add(this.groupBox2);this.panel1.Controls.Add(this.textBox1);this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;this.panel1.Location = new System.Drawing.Point(0, 0);this.panel1.Name = "panel1";this.panel1.Size = new System.Drawing.Size(484, 191);this.panel1.TabIndex = 0;this.panel1.TabStop = true;// // label2// this.label2.AutoSize = true;this.label2.BackColor = System.Drawing.Color.Transparent;this.label2.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label2.Location = new System.Drawing.Point(249, 158);this.label2.Name = "label2";this.label2.Size = new System.Drawing.Size(130, 24);this.label2.TabIndex = 4;this.label2.Text = "白方计时:";// // label1// this.label1.AutoSize = true;this.label1.BackColor = System.Drawing.Color.Transparent;this.label1.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label1.Location = new System.Drawing.Point(26, 158);this.label1.Name = "label1";this.label1.Size = new System.Drawing.Size(130, 24);this.label1.TabIndex = 3;this.label1.Text = "黑方计时:";// // textBox2// this.textBox2.BackColor = System.Drawing.SystemColors.Control;this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;this.textBox2.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.textBox2.ForeColor = System.Drawing.Color.Red;this.textBox2.Location = new System.Drawing.Point(385, 158);this.textBox2.Name = "textBox2";this.textBox2.ReadOnly = true;this.textBox2.Size = new System.Drawing.Size(54, 28);this.textBox2.TabIndex = 2;this.textBox2.Text = "00";this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;// // textBox1// this.textBox1.BackColor = System.Drawing.SystemColors.Control;this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;this.textBox1.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.textBox1.ForeColor = System.Drawing.Color.Red;this.textBox1.Location = new System.Drawing.Point(162, 158);this.textBox1.Name = "textBox1";this.textBox1.ReadOnly = true;this.textBox1.Size = new System.Drawing.Size(54, 28);this.textBox1.TabIndex = 0;this.textBox1.Text = "00";this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;// // panel2// this.panel2.BackColor = System.Drawing.SystemColors.ActiveCaption;this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;this.panel2.Location = new System.Drawing.Point(0, 0);this.panel2.Name = "panel2";this.panel2.Size = new System.Drawing.Size(484, 492);this.panel2.TabIndex = 0;this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);this.panel2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseClick);this.panel2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseMove);// // timer1// this.timer1.Interval = 1000;this.timer1.Tick += new System.EventHandler(this.timer1_Tick);// // Form1// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.BackColor = System.Drawing.SystemColors.Control;this.ClientSize = new System.Drawing.Size(484, 687);this.Controls.Add(this.splitContainer1);this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;this.MaximizeBox = false;this.MinimizeBox = false;this.Name = "Form1";this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;this.Text = "五子棋游戏";this.TopMost = true;this.groupBox1.ResumeLayout(false);this.groupBox1.PerformLayout();this.groupBox2.ResumeLayout(false);this.splitContainer1.Panel1.ResumeLayout(false);this.splitContainer1.Panel2.ResumeLayout(false);((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();this.splitContainer1.ResumeLayout(false);this.panel1.ResumeLayout(false);this.panel1.PerformLayout();this.ResumeLayout(false);}#endregionprivate System.Windows.Forms.GroupBox groupBox1;private System.Windows.Forms.RadioButton radioButton2;private System.Windows.Forms.RadioButton radioButton1;private System.Windows.Forms.GroupBox groupBox2;private System.Windows.Forms.Button button4;private System.Windows.Forms.Button button2;private System.Windows.Forms.Button button3;private System.Windows.Forms.Button button1;private System.Windows.Forms.SplitContainer splitContainer1;private System.Windows.Forms.Panel panel1;private System.Windows.Forms.Panel panel2;private System.Windows.Forms.Button button5;private System.Windows.Forms.TextBox textBox2;private System.Windows.Forms.TextBox textBox1;private System.Windows.Forms.Timer timer1;private System.Windows.Forms.Label label2;private System.Windows.Forms.Label label1;}
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


http://chatgpt.dhexx.cn/article/2OXVmyOs.shtml

相关文章

【Unity连载】斗兽棋-棋类游戏开发演示(2)

第四章 游戏操作与指令 如同养育一个婴儿&#xff0c;父母总会一步步引领孩子成长&#xff0c;从蹒跚学步到来去如风&#xff1b;我们对游戏功能的开发&#xff0c;也无疑应当从走出第一步棋开始。现在&#xff0c;我们已经构建出了棋盘、棋子等基本的游戏逻辑对象&#xff1b…

Java游戏开发——中国象棋联机版

游戏介绍&#xff1a; 中国象棋是起源于中国的一种棋戏&#xff0c;属于二人对抗性游戏的一种&#xff0c;在中国有着悠久的历史。由于规则简单&#xff0c;趣味性强&#xff0c;成为流行极为广泛的棋类游戏。 中国象棋使用方形格状棋盘及红黑二色圆形棋子进行对弈&#xff0c…

【论文】word中三线表的快速简单制作

【论文】word中三线表的快速简单制作 首先&#xff0c;打开word点击插入→表格&#xff0c;选择需要插入表格的行列数&#xff0c;行列数没有关系&#xff0c;因为你插入后可以随意添加行列。 则插入了一下表格&#xff1a; 把你所需要的数据放进去&#xff1a; 之后&#…

如何在word中制作线宽不同的三线表

在word中难免会插入特定的三线表&#xff0c;那就现场给给大家演示一遍 1、打开word&#xff0c;点击插入&#xff0c;点击表格&#xff0c;至于插入几行几列看自己的需求哈。 2、右键点击表格&#xff0c;然后点击表格属性 3、点击边框和底纹&#xff0c;对表格去除相关边线 …

论文中的三线表绘制(word)

步骤 1、选中表格&#xff08;点击下图中的红框部分选中&#xff09; 2、右击表格选择“表格属性” 3、点击边框和底纹&#xff0c;再选择无边框&#xff08;先不要点确定&#xff09; 4、设置三线表的上下边框&#xff08;1.5磅&#xff09;&#xff0c;完成下图之后点击确定-…

word三线表标题两条线之间如何出现空白间隔(论文必备)

为了写论文&#xff0c;我需要把以上的标题转换成下图所示的样子 所实现的步骤如下&#xff1a; 1、把标题内容回车 放在下一行 2、加一条绘制表格的线 3、选中第一行对应位置的两格&#xff0c;合并单元格 并填入内容 可以看到单纯的加上边框&#xff0c;两条线之间是没有空…

Word 2016表格三线表制作

1、打开word&#xff0c;点击插入&#xff0c;插入一个表格。 2、选中表格&#xff0c;点击设计&#xff0c;在边框中的笔画粗细选择1.5磅&#xff0c;然后在边框下拉框先选择无框线&#xff0c;再选择上框线和下框线。然后笔画粗细选择0.5磅&#xff0c;选中第一行后&#x…

三线表的制作

目录 前言参考过程 前言 最近在写些东西的时候&#xff0c;需要用到三线表&#xff0c;上网查了一下&#xff0c;将方法记录下来。 参考 三分钟快速制作论文三线表 过程 (1) 先插入一个表格&#xff0c;然后新建一个表格样式 (2) 如下图所示更改 (3) 点击第二步中的格式&a…

word表格跨页多出一根线(三线表)

在word中做三线表&#xff0c;表格跨页了自动在页底部加一横线&#xff0c;下一页页首加一横线这个怎么去掉么 首先感谢上方在知乎给出解决方案的博主&#xff0c; 接着&#xff1a;文中描述大概操作如下&#xff1a; 如果还是不行&#xff0c;那么就拿来dou一个三线表

Word插入三线表

在Word中插入一个三线表&#xff0c;方法如下所示&#xff1a; 一、先插入一个正常的表格&#xff0c;并输入好相应的数据 二、单击表格的左上角按钮&#xff0c;选中整个表格 选中表格之后&#xff0c;【右键】-【表格属性】&#xff0c;在弹出的表格属性对话框中单击【边框与…

在Word文档中插入三线表

在Word文档中插入三线表 ①插入一个适合你的文字安排的表格 例如&#xff0c;我要如下情况的示例; 则插入一个五行两列的表格并输入数据; 输完数据之后可以全选表格设置字体 全选表格——边框——边框和底纹&#xff1a; 然后按照下列设置&#xff1a; 结果如下; 然后再…

word 三线表 中间辅助线即行线如何断开?

达到如下图的目的&#xff1a; http://www.dxy.cn/bbs/topic/20891892#opennewwindow http://muchong.com/t-4447061-1 总而言之&#xff0c;最简单易行的方法就是多插入一列&#xff0c;然后去掉该列的边框即可&#xff01;

新建论文三线表模板,一键格式刷

论文三线表模板 写在最前面①表设计&#xff0c;新建表格样式②三线表上下线③三线表标题线④设置表格居中⑤设置表头格式容易出错的步骤 写在最前面 论文写完啦&#xff0c;准备调整格式 之前建模也是三线表&#xff0c;但只能基于该文档模板&#xff0c;所以重新设置一下。 …

针对跨页三线表,在Word2016及以上版本中设置表标题和表头在下一页重复以及解决表格跨页处没有下框线的问题

一、在Word2016及以上版本中设置表标题和表头在下一页重复 技巧1&#xff1a;把标题写在表格里&#xff0c;而不是把标题写在表格外&#xff0c;这样表标题也可以跨页重复啦 操作1&#xff1a;选中上述前两行——右击鼠标——选择“表格属性”——选择“行”——勾选“在各页顶…

【办公】word中实现三线表(跨页,续表)

文章目录 前言三线表生成一张表格设置标题和交叉引用设置三线表选中表格的全部设置边框与底纹 设置跨页分割成两个表设置标题行重复 ⭐ 设置续表标识巧妙用文本框 END 前言 在办公中&#xff0c;一些场景需要将普遍表格设设置为三线表(如&#xff1a;论文) 而很多朋友不知道怎…

如何设置三线表线条的粗细

通常编写学生在编写毕业论文时&#xff0c;常用到三线表&#xff0c;而且三线表的线条粗细需要进行设置&#xff0c;使用word进行线条粗细设置时&#xff0c;经常会出现线条粗细不变的情况&#xff0c;以下使用图文形式说明设置过程。 将word的显示调整为100%&#xff0c;如图…

word制作三线表及保存模板

制作三线表 插入---表格 delete删除表格内容 backspace删除表格 开始菜单下选择有无框线 选中表格---布局---查看网格线&#xff08;无框线下显示表格形状&#xff09; 点击表格---表设计---调整磅数---边框刷刷需要更改的边线 上下1.5磅&#xff0c;中间0.5磅 使行间距…

Word三线表创建

三线表是论文写作中经常使用到的表格格式 自定义三线表 “插入”-->“表格”&#xff0c;随便插入一个表格&#xff0c;然后将光标移动到表格内 “表设计”-->“其他”-->“新建表格样式” 修改模板名称为“三线表”&#xff0c;方便下次直接套用 首先设置标题行【…

【软件使用】Word、WPS如何制作三线表

以下教程为在WPS中演示&#xff0c;Word的操作会有细节上的不同 三线表制作教程 1 插入表格2 内容调整3 三线表制作 1 插入表格 插入表格&#xff0c;输入表格内的数据 2 内容调整 可以看到表格中的文字没有居中对齐&#xff0c;接下来对文字进行简单的调整。 &#xff08;1…

word如何制作三线表

1.插入指定行列数的表格 举例插入4*8的表格 2.去除多余线条&#xff0c;制作2线表 选择表格&#xff0c;右击选择表格属性-》边框和底纹-》 选择“无”&#xff0c;去掉所有线条 选择“直线条”&#xff0c;单击上边框标志和下边框标志 3.添加第三条线 选中第一行 右击-》“…