![]() |
#2
qinxiaowan2012-06-11 19:03
Hebe CYaMaXunDlg::Computer()//搜索和评估
{ int count=0; Hebe GetResult; GetResult.bar_x=1;GetResult.bar_y=1;GetResult.chess_x=1;GetResult.chess_y=1;GetResult.x=1; return GetResult; } Hebe CYaMaXunDlg::Computer1() { BYTE position[12][12]; for(int i=0;i<12;i++) { for(int j=0;j<12;j++) { position[i][j]=1; } } for(i=1;i<11;i++) { for(int j=1;j<11;j++) { position[i][j]=Broad[i-1][j-1]; } } Searchengine A; move bestmove; ////////////计时 int timecount; extern int ec ; extern int testc; extern int node; timecount = GetTickCount(); bestmove=A.searchagoodmove(position); Hebe a; a.bar_x=bestmove.barx-1;a.bar_y=bestmove.bary-1; a.chess_x=bestmove.x-1;a.chess_y=bestmove.y-1; a.x=bestmove.lx-1;a.y=bestmove.ly-1; a.score=testc;//ec;//A.num; a.timecount=GetTickCount() - timecount; a.node=node; B=bestmove.score; c=a.node; ss[1].barx=a.bar_x; ss[1].bary=a.bar_y; ss[1].lx=a.x; ss[1].ly=a.y; ss[1].x=a.chess_x; ss[1].y=a.chess_y; return a; } int CYaMaXunDlg::Is_OK(int x1,int y1,int x,int y,int tep[10][10])//判断电脑生成的招数是否符合规则 { if(x1==x||y1==y||(y1-x1)==(y-x)||(x+y)==(x1+y1)) { if(x1==x) { if(y1>y) { for(int i=y+1;i<y1;i++) if(tep[x][i]==1||tep[x][i]==2||tep[x][i]==3) return 0; } else { for(int i=y1+1;i<y;i++) if(tep[x][i]==1||tep[x][i]==2||tep[x][i]==3) return 0; } } if(y1==y) { if(x1>x) { for(int i=x+1;i<x1;i++) if(tep[i][y]==1||tep[i][y]==2||tep[i][y]==3) return 0; } else { for(int i=x1+1;i<x;i++) if(tep[i][y]==1||tep[i][y]==2||tep[i][y]==3) return 0; } } if((y1-x1)==(y-x)) { int k=y-x; if(y1>y) { for(int i=y+1;i<y1;i++) if(tep[i-k][i]==1||tep[i-k][i]==2||tep[i-k][i]==3) return 0; } else { for(int i=y1+1;i<y;i++) if(tep[i-k][i]==1||tep[i-k][i]==2||tep[i-k][i]==3) return 0; } } if((y1+x1)==(y+x)) { int k=y+x; if(y1>y) { for(int i=y+1;i<y1;i++) if(tep[k-i][i]==1||tep[k-i][i]==2||tep[k-i][i]==3) return 0; } else { for(int i=y1+1;i<y;i++) if(tep[k-i][i]==1||tep[k-i][i]==2||tep[k-i][i]==3) return 0; } } return 1; } return 0; } void CYaMaXunDlg::OnButton1() { Broad[ss[1].barx][ss[1].bary]=0; Broad[ss[1].lx][ss[1].ly]=Broad[ss[1].x][ss[1].y]; Broad[ss[1].x][ss[1].y]=0; Broad[ss[0].barx][ss[0].bary]=0; Broad[ss[0].lx][ss[0].ly]=Broad[ss[0].x][ss[0].y]; Broad[ss[0].x][ss[0].y]=0; Invalidate(FALSE); // TODO: Add your control notification handler code here } NodeOfSave * CYaMaXunDlg::MyInit() { NodeOfSave temp; NodeOfSave *p; NodeOfSave *p1; NodeOfSave *head; FILE *fp; int i,j; if((fp=fopen("data.dat","r"))!=NULL) { fread(&temp,sizeof(struct NodeOfSave),1,fp); p1=(NodeOfSave *)malloc(sizeof(struct NodeOfSave)); head=p1; p1->count=temp.count; p1->Dcount=temp.Dcount; p1->Mcount=temp.Mcount; p1->Next=NULL; for(i=0;i<10;i++) { for(j=0;j<10;j++) { p1->Data[i][j]=temp.Data[i][j]; } } p1->result.barx=temp.result.barx; p1->result.bary=temp.result.bary; p1->result.lx=temp.result.lx; p1->result.ly=temp.result.ly; p1->result.x=temp.result.x; p1->result.y=temp.result.y; while(fread(&temp,sizeof(struct NodeOfSave),1,fp)) { p=(NodeOfSave *)malloc(sizeof(struct NodeOfSave)); p->count=temp.count; p->Dcount=temp.Dcount; p->Mcount=temp.Mcount; p->Next=NULL; // MessageBox("此模式是人人!","提示"); for(i=0;i<10;i++) { for(j=0;j<10;j++) { p->Data[i][j]=temp.Data[i][j]; } } p->result.barx=temp.result.barx; p->result.bary=temp.result.bary; p->result.lx=temp.result.lx; p->result.ly=temp.result.ly; p->result.x=temp.result.x; p->result.y=temp.result.y; p1->Next=p; p1=p; }; fclose(fp); } return head; } |
Hebe CYaMaXunDlg::Computer()//搜索和评估
{
int count=0;
Hebe GetResult;
GetResult.bar_x=1;GetResult.bar_y=1;GetResult.chess_x=1;GetResult.chess_y=1;GetResult.x=1;
return GetResult;
}
Hebe CYaMaXunDlg::Computer1()
{
BYTE position[12][12];
for(int i=0;i<12;i++)
{
for(int j=0;j<12;j++)
{
position[i][j]=1;
}
}
for(i=1;i<11;i++)
{
for(int j=1;j<11;j++)
{
position[i][j]=Broad[i-1][j-1];
}
}
Searchengine A;
move bestmove;
////////////计时
int timecount;
extern int ec ;
extern int testc;
extern int node;
timecount = GetTickCount();
bestmove=A.searchagoodmove(position);
Hebe a;
a.bar_x=bestmove.barx-1;a.bar_y=bestmove.bary-1;
a.chess_x=bestmove.x-1;a.chess_y=bestmove.y-1;
a.x=bestmove.lx-1;a.y=bestmove.ly-1;
a.score=testc;//ec;//A.num;
a.timecount=GetTickCount() - timecount;
a.node=node;
B=bestmove.score;
c=a.node;
ss[1].barx=a.bar_x;
ss[1].bary=a.bar_y;
ss[1].lx=a.x;
ss[1].ly=a.y;
ss[1].x=a.chess_x;
ss[1].y=a.chess_y;
return a;
}
int CYaMaXunDlg::Is_OK(int x1,int y1,int x,int y,int tep[10][10])//判断电脑生成的招数是否符合规则
{
if(x1==x||y1==y||(y1-x1)==(y-x)||(x+y)==(x1+y1))
{
if(x1==x)
{
if(y1>y)
{
for(int i=y+1;i