資源簡介
使用C#Winform實(shí)現(xiàn)五子棋人機(jī)及局域網(wǎng)功能,二維數(shù)組畫棋盤。

代碼片段和文件信息
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為棋盤情況數(shù)組,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;
????????//判斷當(dāng)前棋子是黑(true)是白(false)
????????public?bool?stoneflag?=?true;
????????//判斷先手玩家(是電腦(true)還是人(false),先手下黑棋)
????????private?bool?mplayfirstflag?=?false;
????????//歷史記錄堆棧
????????private?Stack?mStarckHistory?=?new?Stack();
????????public?bool?a?=?true;//判斷只有點(diǎn)擊開始時才可進(jìn)行落子
????????//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;
????????????}
????????????//判斷結(jié)果
????????????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??Fivestones\Fivestones\Properties\AssemblyInfo.cs
?????文件????????249??2018-04-16?15:23??Fivestones\Fivestones\Properties\Settings.settings
?????文件???????1097??2018-04-16?15:23??Fivestones\Fivestones\Properties\Settings.Designer.cs
?????文件???????6707??2018-04-16?18:31??Fivestones\Fivestones\Properties\Resources.resx
?????文件???????3994??2018-04-16?18:31??Fivestones\Fivestones\Properties\Resources.Designer.cs
?????文件???????1682??2018-04-16?15:24??Fivestones\Fivestones\Properties\whitestone.gif
?????文件???????1723??2018-04-16?15:24??Fivestones\Fivestones\Properties\blackstone.gif
?????文件?????161859??2018-04-16?15:24??Fivestones\Fivestones\Properties\chessboard.gif
?????文件????????187??2018-04-16?15:23??Fivestones\Fivestones\App.config
?????文件???????2036??2018-05-29?11:52??Fivestones\Fivestones\Form1.cs
?????文件???????3486??2018-05-16?18:09??Fivestones\Fivestones\Form1.Designer.cs
?????文件????????523??2018-06-06?13:58??Fivestones\Fivestones\Program.cs
?????文件???????7854??2018-06-06?13:56??Fivestones\Fivestones\Fivestones.csproj
?????文件???????5817??2018-05-16?18:09??Fivestones\Fivestones\Form1.resx
?????文件???????6487??2018-05-31?20:23??Fivestones\Fivestones\chessboard.cs
?????文件???????1692??2018-06-05?21:50??Fivestones\Fivestones\Stone.cs
?????文件???????1723??2018-04-16?15:24??Fivestones\Fivestones\blackstone.gif
?????文件?????161859??2018-04-16?15:24??Fivestones\Fivestones\chessboard.gif
?????文件???????1682??2018-04-16?15:24??Fivestones\Fivestones\whitestone.gif
?????文件???????1723??2018-04-16?18:30??Fivestones\Fivestones\Resources\blackstone.gif
?????文件?????161859??2018-04-16?18:30??Fivestones\Fivestones\Resources\chessboard.gif
?????文件???????1682??2018-04-16?18:30??Fivestones\Fivestones\Resources\whitestone.gif
?????文件??????13441??2018-05-22?14:40??Fivestones\Fivestones\rules.cs
?????文件??????14918??2018-06-06?12:21??Fivestones\Fivestones\Form2.cs
?????文件???????4487??2018-05-28?11:32??Fivestones\Fivestones\Form2.Designer.cs
?????文件???????5817??2018-05-16?17:33??Fivestones\Fivestones\Form2.resx
?????文件????????641??2018-04-25?05:08??Fivestones\Fivestones\Fivestones.csproj.user
?????文件???????1488??2018-05-23?16:47??Fivestones\Fivestones\creatroom.cs
?????文件???????6227??2018-05-10?22:05??Fivestones\Fivestones\creatroom.Designer.cs
?????文件???????5817??2018-05-10?22:05??Fivestones\Fivestones\creatroom.resx
............此處省略126個文件信息
評論
共有 條評論