1、 Label2: Label3: BitBtn1: TBitBtn; BitBtn3: Label4: s1: N1: N2: N3: N4: N5: N6: N7: N8: GroupBox1: TGroupBox; PaintBox2: BitBtn2: BitBtn4: BitBtn5: BitBtn6: GroupBox2: Memo1: TMemo; BitBtn7: N9: N10: N11: N12: N13: RadioGroup1: TRadioGroup; RadioGroup2: procedure FormCreate(Sender: TObject); procedu
2、re PaintBox1Paint(Sender: procedure NewGame1Click(Sender: procedure Eixt1Click(Sender: procedure CrossPaint(x,y,i,j:integer); /自定义画兵格过程 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FindDrop(NowR,NowC: /扫描可以走棋的点过程 procedure PaintCMo
3、veDrop(); /画出可走点过程 procedure WhoWin(); /判断输赢过程 procedure IsNextWin();/判断是否将军 procedure RemHistory();/走棋记录 procedure RepentChess(n: procedure FindAGoodMove(); /寻找一个优秀的走法 procedure AddPoint(row,column:/加入一个相关点 function Eveluate(nSide:integer):integer;/估值函数 function Eveluate1(nSide:/测试估值函数 function Get
4、RelatePiece(row,column:/枚举一个位置上棋子所有相关的点 function GetBingValue(row,column:/为兵返回附加值 /创建可能的走法 nPly记录扫描的层数,nSide记录到那边走棋 0为红方,1为黑方 function CreatePossibleMove(nPly,nSide: function MakeMove(depth,n:/猜想过程中生产一个新局面 procedure UnMakeMove(depth,n,nChessID: /猜想过程中根据走法恢复一个棋盘 function IsGameOver(depth:/猜想过程中判断给定局面
5、是否结束 function AddMove(FormR,FormC,ToR,ToC,nPly:/在nMoveList中插入一个走法 function NegaMax(depth: /深度优先搜索负极大技校 function Alpha_Beta(depth,alpha,beta:/Alpha-Beta搜索算法 function ChessMoveLaw(NowR,NowC,ToR,ToC,nChessID:boolean; /走棋规则函数 function ChessMoveLawPos(NowR,NowC,ToR,ToC,nChessID: /猜想过程走棋规则函数 function CanT
6、ouch(NowR,NowC,ToR,ToC,nChessID:/判断能不能到达目标点 function ChessPutLaw(NowR,NowC,ToR,ToC: /摆起规则函数 function ChessMove(NowR,NowC,ToR,ToC: /走棋函数 function AIChessMove(NowR,NowC,ToR,ToC: /电脑走棋 procedure BitBtn1Click(Sender: procedure FormPaint(Sender: procedure BitBtn3Click(Sender: procedure N3Click(Sender: pr
7、ocedure N2Click(Sender: procedure N6Click(Sender: procedure N7Click(Sender: procedure PaintBox2Paint(Sender: procedure N8Click(Sender: procedure PaintBox2MouseDown(Sender: procedure BitBtn5Click(Sender: procedure BitBtn4Click(Sender: procedure BitBtn2Click(Sender: procedure BitBtn6Click(Sender: proc
8、edure BitBtn7Click(Sender: procedure N11Click(Sender: procedure N12Click(Sender: procedure N13Click(Sender: private Private declarations public Public declarations end;var Form1: TForm1;/棋盘格子单位大小mBit:/棋子数组:所有棋子的数值mChess: array1.14 of string =(车,马相士帅炮兵車馬象仕将卒);/=棋子价值=/棋子的基础价值m_BaseValue: array1.14 of
9、integer=(500,350,250,250,10000,370,100,500,350,250,250,10000,370,100);/棋子灵活度基础价值m_Flexible:array1.14 of integer=(6,12,1,1,0,6,15,6,12,1,1,0,6,15);/每一个位置上的棋子的灵活性 即可走步数m_FlexibleNum:array1.10,1.9of integer;/每一个位置被威胁的信息m_AttackNum:/每一个位置被保护的信息m_GuardNum:/每一个棋子是总价值m_ChessValue:/红兵附加值矩阵mBing:array1.10,1.9of integer=(0,0,0,0,0,0,0,0,0),(90,90,110,120,120,120,110,90,90),(70,90,110,110,110,110,110,90,70),(70,70,70,70,70,70,70,70,70),(0,0,0,0,0,0,0,0,0)/黑卒附加值矩阵mZhuzi:/=棋子
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1