unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ExtCtrls, StdCtrls, Buttons,Unit2,Unit3;
type TForm1 = class(TForm) PaintBox1: TPaintBox; MainMenu1: TMainMenu; Game1: TMenuItem; NewGame1: TMenuItem; Eixt1: TMenuItem; Label1: TLabel; Label2: TLabel; Label3: TLabel; BitBtn1: TBitBtn; BitBtn3: TBitBtn; Label4: TLabel; s1: TMenuItem; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; N8: TMenuItem; GroupBox1: TGroupBox; PaintBox2: TPaintBox; BitBtn2: TBitBtn; BitBtn4: TBitBtn; BitBtn5: TBitBtn; BitBtn6: TBitBtn; GroupBox2: TGroupBox; Memo1: TMemo; BitBtn7: TBitBtn; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; N12: TMenuItem;
N13: TMenuItem; RadioGroup1: TRadioGroup; RadioGroup2: TRadioGroup; procedure FormCreate(Sender: TObject); procedure PaintBox1Paint(Sender: TObject); procedure NewGame1Click(Sender: TObject); procedure Eixt1Click(Sender: TObject); procedure CrossPaint(x,y,i,j:integer); //自定义画兵格过程 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FindDrop(NowR,NowC:integer); //扫描可以走棋的点过程 procedure procedure procedure procedure procedure procedure procedure PaintCMoveDrop(); //画出可走点过程 WhoWin(); //判断输赢过程 IsNextWin();//判断是否将军 RemHistory();//走棋记录 RepentChess(n:integer); FindAGoodMove(); //寻找一个优秀的走法 AddPoint(row,column:integer);//加入一个相关点
function Eveluate(nSide:integer):integer;//估值函数 function Eveluate1(nSide:integer):integer;//测试估值函数 function GetRelatePiece(row,column:integer):integer;//枚举一个位置上棋子所有 相关的点 function GetBingValue(row,column:integer):integer;//为兵返回附加值 //创建可能的走法 nPly 记录扫描的层数,nSide 记录到那边走棋 0 为红方,1 为黑方 function CreatePossibleMove(nPly,nSide:integer):integer; function MakeMove(depth,n:integer):integer;//猜想过程中生产一个新局面 procedure UnMakeMove(depth,n,nChessID:integer); //猜想过程中根据走法恢复一 个棋盘 function IsGameOver(depth:integer):integer;//猜想过程中判断给定局面是否结束 function AddMove(FormR,FormC,ToR,ToC,nPly:integer):integer;//在 nMoveList 中插 入一个走法 function NegaMax(depth:integer):integer; //深度优先搜索负极大技校 function Alpha_Beta(depth,alpha,beta:integer):integer;//Alpha-Beta
搜索算法 function ChessMoveLaw(NowR,NowC,ToR,ToC,nChessID:integer):boolean; //走棋规 则函数 function ChessMoveLawPos(NowR,NowC,ToR,ToC,nChessID:integer):boolean; // 猜 想过程走棋规则函数 function CanTouch(NowR,NowC,ToR,ToC,nChessID:integer):boolean;//判断能不能到 达目标点 function ChessPutLaw(NowR,NowC,ToR,ToC:integer):boolean; //摆起规则函数 function ChessMove(NowR,NowC,ToR,ToC:integer):boolean; //走棋函数 function AIChessMov
e(NowR,NowC,ToR,ToC:integer):boolean; //电脑走棋
procedure BitBtn1Click(Sender: TObject); procedure FormPaint(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure Pain