資源簡介
一個圍棋 吃子 算死活的算法 調試可以運行,很有參考價值

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Drawing;
using?System.IO;
using?ChessBlock?=?System.Collections.ArrayList;
namespace?go
{
????public?class?Board
????{
????????private?static?int?margin_top?=?50;
????????private?static?int?margin_left?=?20;
????????private?static?int?gap?=?20;
????????private?static?int?chessSize?=?8;
????????private?static?int?numberSize?=?6;
????????private?static?int?starSize?=?3;
????????private?Chess[]?m_Board?=?new?Chess[19?19];
????????private?BoardRecorder?m_recorder;
????????private?Chess?m_LastChess;
????????private?Chess?m_LastSingleChessEatten;
????????private?int?m_currentStep;
????????private?bool?m_bShowIndex?=?false;
????????public?Board()
????????{
????????????clear();
????????????//?For?Test
????????????//?bool?bSuccess?=?loadBoardFromFile(“init.txt“);
????????}
????????public?Chess?lastChess?{?get?{?return?m_LastChess;?}?}
????????public?bool?showIndex
????????{
????????????get?{?return?m_bShowIndex;?}
????????????set?{?m_bShowIndex?=?value;?}
????????}
????????public?Chess.POS?mapPointsToBoard(int?pointX?int?pointY)
????????{
????????????Chess.POS?pos;
????????????pos.posX?=?(pointX?-?margin_left?+?gap/2)?/?gap;
????????????pos.posY?=?(pointY?-?margin_top?+?gap/2)?/?gap;
????????????if?(!pos.isValid)
????????????????pos.setToInvalid();
????????????return?pos;
????????}
????????public?void?draw(Graphics?g)
????????{
????????????drawBorder(g);
????????????drawChess(g);
????????}
????????public?bool?addChess(Chess.POS?pos?Chess.ChessType?type)
????????{
????????????if?(type?!=?Chess.ChessType.Black?&&?type?!=?Chess.ChessType.White)
????????????????return?false;
????????????//?we?can?only?put?chess?on?empty?cells
????????????if?(m_Board[pos.posX?pos.posY].type?!=?Chess.ChessType.Empty)
????????????????return?false;
????????????//?put?the?chess?on?the?board?first
????????????m_Board[pos.posX?pos.posY].type?=?type;
????????????//?can?we?eat?others?
????????????bool?bEat?=?false;
????????????bool?bValidStep?=?true;
????????????if?(pos.hasLeft?&&?m_Board[pos.posX?-?1?pos.posY].type?==?Chess.oppsiteType(type))
????????????{
????????????????bEat?=?tryToEat(pos?new?Chess.POS(pos.posX?-?1?pos.posY)?ref?bValidStep)?||?bEat;
????????????????if?(!bValidStep)
????????????????????return?false;
????????????}
????????????if?(pos.hasRight?&&?m_Board[pos.posX?+?1?pos.posY].type?==?Chess.oppsiteType(type))
????????????{
????????????????bEat?=?tryToEat(pos?new?Chess.POS(pos.posX?+?1?pos.posY)?ref?bValidStep)?||?bEat;
????????????????if?(!bValidStep)
????????????????????return?false;
????????????}
????????????if?(pos.hasUp?&&?m_Board[pos.posX?pos.posY?-?1].type?==?Chess.oppsiteType(type))
????????????{
????????????????bEat?=?tryToEat(pos?new?Chess.POS(pos.posX?pos.posY?-?1)?ref?bValidStep)?||?bEat;
????????????????if?(!bValidStep)
????????????????????return?false;
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2009-02-01?16:12??go\
?????目錄???????????0??2009-02-01?16:13??go\go\
?????文件???????31232??2009-02-01?16:11??go\go.exe
?????文件?????????896??2009-01-16?16:23??go\go.sln
?????文件???????35328??2009-02-01?16:12??go\go.suo
?????文件?????????120??2009-02-01?16:06??go\go\app.config
?????文件???????31272??2009-02-01?16:11??go\go\Board.cs
?????文件????????1747??2009-02-01?16:11??go\go\BoardRecorder.cs
?????文件????????3938??2009-02-01?16:11??go\go\Chess.cs
?????文件????????4004??2009-02-01?16:10??go\go\go.csproj
?????文件????????1078??2009-02-01?16:10??go\go\go.ico
?????文件????????9524??2009-02-01?16:11??go\go\MainForm.cs
?????文件???????21288??2009-01-22?17:37??go\go\MainForm.Designer.cs
?????文件????????6015??2009-01-22?17:37??go\go\MainForm.resx
?????文件?????????477??2009-02-01?16:11??go\go\Program.cs
?????目錄???????????0??2009-01-19?16:27??go\go\Properties\
?????文件????????1398??2009-01-19?16:27??go\go\Properties\AssemblyInfo.cs
?????文件????????2833??2009-01-16?16:23??go\go\Properties\Resources.Designer.cs
?????文件????????5612??2009-01-16?16:23??go\go\Properties\Resources.resx
?????文件????????1087??2009-01-16?16:23??go\go\Properties\Settings.Designer.cs
?????文件?????????249??2009-01-16?16:23??go\go\Properties\Settings.settings
?????文件?????????364??2009-02-01?16:11??go\go\Utils.cs
- 上一篇:IMEI號生成器
- 下一篇:BrandNewShape簡單流程圖工具
評論
共有 條評論