面向对象期中作业-五子棋程序设计作业

上传人:aa****6 文档编号:30009934 上传时间:2018-01-26 格式:DOC 页数:20 大小:728KB
返回 下载 相关 举报
面向对象期中作业-五子棋程序设计作业_第1页
第1页 / 共20页
面向对象期中作业-五子棋程序设计作业_第2页
第2页 / 共20页
面向对象期中作业-五子棋程序设计作业_第3页
第3页 / 共20页
面向对象期中作业-五子棋程序设计作业_第4页
第4页 / 共20页
面向对象期中作业-五子棋程序设计作业_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《面向对象期中作业-五子棋程序设计作业》由会员分享,可在线阅读,更多相关《面向对象期中作业-五子棋程序设计作业(20页珍藏版)》请在金锄头文库上搜索。

1、面向对象期中作业五子棋程序设计一、五子棋的由来五子棋是我国古代的、传统的黑白棋种之一,大约在南北朝时期随围棋一起先后传入朝鲜、日本等地。五子棋在日本叫“连珠棋” 。通过一系列的规则变化使连珠五子棋这一简单的游戏复杂化、规范化,而最终成为今天的职业连珠五子棋,同时也成为一种国际比赛棋。二、五子棋的棋盘 棋盘正中一点为“天元”。棋盘两端的横线称端线。棋盘左右最外边的两条纵线称边线。从两条端线和两条边线向正中发展而纵横交叉在第四条线形成的四个点称为“星” 。天元和星应在棋盘上用小圆点标出。 以持黑方为准,棋盘上的纵轴线从左到右用英文字母 AO 标记。横行线从远到近用阿拉伯数字 115 标记。纵横轴上

2、的横纵线交叉点分别用横纵线标记的名称合写成。三、五子棋规则 1、行棋顺序 黑先、 白后,从天元开始相互顺序落子。 2、判断胜负 最先在棋盘横向、竖向、斜向形成连续的相同色五个棋子的一方为胜。 黑棋禁手判负(Lose),白棋无禁手。黑棋禁手包括“三、三”(Double Three)(包括“四、三、三 ”)、“四、四 ”(Double Four)(包括“四、四、三”)、“ 长连”(Overline)。黑棋只能以 “四、三”取胜。 如分不出胜负,则定为平局(Draw)。 五连与禁手同时形成,先五为胜。 黑方禁手形成时,白方应立即指出。若白方未发现或发现后未指明而继续应子,则不能判黑方负。 3、规则的

3、解释 术语介绍: 、阳线和阴线 1、 阳线:棋盘上可见的横纵直线。 2、 阴线:棋盘上无实线连接的隐形斜线。 、连:在棋阳线和阴线的任意一条线上形成的有 5 个或 5 个以上的同色棋子不间隔地紧紧相连。 1、 五连:在棋盘上形成的 5 个同色棋子的连。 2、 长连:在棋盘上形成的 6 个或 6 个以上同色棋子的连 。 、四 包括 活四和冲四。 1、活四:在棋盘某一条阳线或阴线上有同色 4 子不间隔地紧紧相连,且在此 4 子两端延长线上各有一个无子的交叉点与此 4 子紧密相连。 2、冲四:除 活四外的,再下一着棋便可形成五连,并且存在五连的可能性的局面。 3、 白棋再下一着可形成长连的局面也视为

4、 四 。 、三 指活三,包括连三 和跳三。 1、连三:在棋盘某一条阳线或阴线上有同色三子相连,且在此三子两端延长线上有一端至少有一个,另一端至少有两个无子的交叉点与此三子紧密相连。2、跳三:中间仅间隔一个无子交叉点的连三,但两端延长线均至少有一个无子的交叉点与此三子相连。 、禁手:对局中禁止使用的着法。 1、黑棋禁手包括 三三 、四四 和长连 。 1.1 三三:由于黑方走一着在无子交叉点上同时形成二个或二个以上黑方 活的局面。 1.2 四四:由于黑方走一着在无子交叉点上同时形成二个或二个以上黑方 四的局面。 2、白棋无禁手。 、四三:指某一方同时具备两个先手,其中一个是 四,一个是 活三。 w

5、hiteblacknoe结 束开 始白 棋 请 求 黑 棋 请 求历 史 纪 录 记 时悔 棋 暂 停继 续判 断 胜 负白 方 胜 黑 方 胜退 出新 游 戏 平 局活 动 图先手:对方必须应答的着法,其中冲四 称为绝对先手。 、三手可交换:是指黑棋下盘面第 3 着棋后,白方在应白之前,如感觉黑方棋形不利于己方,可提出交换,即执白棋一方变为执黑棋一方,而黑方不可以不换。 、五手两打:是指黑棋在下盘面上关键的第 5 手棋时,必须下两步棋,让白棋在这两步棋中任选一步,然后再继续对弈。一般说来,白棋肯定拿掉对白方不利的一点,而保留对黑方较为不利的那点让黑方行棋。四、UML 图五、功能介绍白 棋黑

6、棋 退 出游 戏 暂 停继 续思 考 计 时游 戏 等 待 开 始 历 史 记 录 胜 负 情 况用 例 图-结 束 1* -结 束 2*OR结 束 3*-结 束 4*结 束 -结 束 2* 历 史 记 录状 态 图白 、 黑 双 方 都 没 有 开 始 悔 棋暂 停继 续+开 始 () :void悔 棋 () :i+暂 停 () :void继 续 () :i+白 方 胜 () :int黑 方 胜 () :it+平 局 () :void-sj :bol =turetar :l fals-ply :int =0nla :it 五 子 棋+win( ) ()timer1_Tick()+ChckGa

7、eRsult()-play :it胜 负 判 定 +Point MToA()Rest()+DrawCheckrBoard()eNxtPlyeMark()+rahes()AdC棋 盘 绘 制-结 束 1*结 束 2* -结 束 3*-结 束 4*类 图开始:游戏设置,点击开始或选择新游戏菜单方能开始游戏。暂停和继续:是用时间计数器来规定没有棋手有 15 秒钟的下棋思考时间,期间可以暂停时间和继续时间,15 秒倒计时结束,还未下棋系统将其至为自动放弃,系统判定此局为负。历史记录:历史纪录中记录了棋手每次下棋,所落子的位置,这样是棋手可查询本盘棋所有落子的位置。悔棋:在感觉落子有误时,方可使用悔棋功

8、能,每执行一次,系统将把执行前所下的一步棋,将其清除,使得下棋更人性化。六、代码及注释using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Net;using System.Net.Sockets;using System.Text;using System.IO;using System.Threading;namespace game/ / fiveches

9、s 的摘要说明。/ public class fivechess : System.Windows.Forms.Formprivate System.Windows.Forms.MainMenu mainMenu1;private System.Windows.Forms.MenuItem menuItem1;private System.Windows.Forms.MenuItem menuItem5;private System.Windows.Forms.MenuItem menuItem6;private System.ComponentModel.IContainer compone

10、nts;private System.Windows.Forms.ImageList imageList1;private const int None = -1;/没有棋子private const int White = 0;/代表白棋private const int Black = 1;/代表黑棋private int timecount=15;private int ,checkerBoard = new int 15, 15;/棋盘(用来保存每一个棋子)private int nextPlayer;/下一个选手bool sj = true;bool start = false;pr

11、ivate int Playergetreturn nextPlayer;setnextPlayer = value;ReDrawNextPlayerMark();private System.Windows.Forms.MenuItem menuItem9;/下一次该黑棋还是白棋下private Stack History;/下棋的历史记录private System.Windows.Forms.MenuItem menuItem2;private System.Windows.Forms.GroupBox groupBox2;private System.Windows.Forms.Lis

12、tBox lstHistory;private System.Windows.Forms.GroupBox groupBox1;private System.Windows.Forms.TextBox Time;private System.Windows.Forms.Button stop;private System.Windows.Forms.Button goon;private System.Windows.Forms.Label lb;private System.Windows.Forms.Button startBT;private System.Windows.Forms.T

13、imer timer1;public fivechess()/ Required for Windows Form Designer support/InitializeComponent();/ TODO: Add any constructor code after InitializeComponent call/ checkerBoard = new int 15,15;History = new Stack();Player = White;/默认设置为白棋先下Reset();/ / 清理所有正在使用的资源。/ protected override void Dispose( boo

14、l disposing )if( disposing )if(components != null)components.Dispose();base.Dispose( disposing );#region Windows Form Designer generated code/ / Required method for Designer support - do not modify/ the contents of this method with the code editor./ private void InitializeComponent()ponents = new Sy

15、stem.ComponentModel.Container();System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(fivechess);this.menuItem9 = new System.Windows.Forms.MenuItem();this.menuItem5 = new System.Windows.Forms.MenuItem();this.menuItem6 = new System.Windows.Forms.MenuItem();this.menu

16、Item1 = new System.Windows.Forms.MenuItem();this.mainMenu1 = new System.Windows.Forms.MainMenu();this.menuItem2 = new System.Windows.Forms.MenuItem();this.imageList1 = new System.Windows.Forms.ImageList(ponents);this.groupBox2 = new System.Windows.Forms.GroupBox();this.lstHistory = new System.Windows.Forms.ListBox();this.gro

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号