资源描述:
《【精品】中国象棋Delphi版本程序代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、unitUnitl;interfaceusesForms,Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Dialogs,Menus,ExtCtrls,StdCtrls,Buttons,Uni12,Unit3;typeTFoi'ml=class(TForm)PaintBoxl:TPaintBox;MainMenu1:TMainMenu;Gamel:TMenultem;NewGame1:TMenuItem;Eixtl:TMenuItem;Label1:TLabel
2、;Label2:TLabel;Label3:TLabel;BitBtnl:TBitBtn;BitBtn3:TBitBtn;Label4:TLabel;si:TMenuTtem;N1:TMenuItem;N2:TMenuItem;N3:TMenuItem;N4:TMenuTtem;N5:TMenu!tem;N6:TMenu!tem;N7:TMenultem;N8:TMenultem;GroupBox1:TGroupBox;PaintBox2:TPaintBox;BitBtn2:TBitBtn;BitBtn4:TBitBtn;BitBtn
3、5:TBitBtn;BitBtn6:TBitBtn;GroupBox2:TGroupBox:Memol:TMemo;BitBtn7:TBitBtn;N9:TMenuItem;N10:TMenuItem;N11:TMenuItem;N12:TMenuItem;N13:TMenuItem;RadioGroupl:TRadioGroup;procedureprocedureprocedureprocedureRadioGroup2:TRadioGroup;FormCreate(Sender:TObject);PaintBoxlPaint(S
4、ender:TObject);NcwGamclClick(Sender:TObject);EixtlClick(Sender:TObject);procedureCrossPaint(x,y,i,j•integer);//自定义iHii兵格过程procedurePaintBoxlMouseDown(Sender:TObject;Button:TMouseButton;Shift:TShiftState;X,Y:Integer);FindDrop(NowR,NowC:integer);//扫描可以走棋的点过程procedureproce
5、dureprocedureprocedureprocedureprocedureprocedureprocedurePaintCMoveDrop0;//画出可走点过程WhoWinO;//判断输赢过程IsNextWinO;//判断是否将军ReniHistory();//走棋记录RepentChess(n:integer);FindAGoodMoveO;//寻找一个优秀的走法functionfunctionfunction相关的点functionAddPoint(row,column:integer);//加入一个相关点Eveluate(
6、nSide:integer):integer;//估值函数Eveluatel(nSide:integer):integer;//测试估值函数GetRolate?iece(row,column:integer):integer;//枚举一个位置上棋子所有GetBingValue(row,column:integer):integer;//为兵返回附加值//创建可能的走法nPly记录扫描的层数,nSide记录到那边走棋0为红方,1为黑方functionCreatePossibleMove(nPly,nSide:integer):integ
7、er;functionMakeMove(depth,n:integer):integer;//猜想过程中生产一个新局面procedureUnMakeMove(depth,n,nChesslD:integer);//猜想过程屮根据走法恢复一个棋盘functionIsGameOver(depth:integer):integer;//猜想过程中判断给定局而是否结束NegaMax(depth:integer):integer;//深度优先搜索负极人技校Alpha_Beta(depth,alpha,beta:integer):integer;
8、//Alpha-Beta搜索算法ChessMoveLaw(NowR,NowC,ToR,ToC,nChessID:integer):boolean;//走棋规functionAddMove(FormR,FormC,ToR,