| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 459 人关注过本帖
标题:看不懂这个程序,谁能帮我讲解一下这个亚马逊博弈搜索和评估的程序段,最好 ...
只看楼主 加入收藏
qinxiaowan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-11
收藏
 问题点数:0 回复次数:1 
看不懂这个程序,谁能帮我讲解一下这个亚马逊博弈搜索和评估的程序段,最好说明一下这个程序代码用了什么算法,谢谢
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
搜索更多相关主题的帖子: 搜索 评估 position return count 
2012-06-11 18:42
qinxiaowan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-11
收藏
得分:0 
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;

}
2012-06-11 19:03
快速回复:看不懂这个程序,谁能帮我讲解一下这个亚马逊博弈搜索和评估的程序段, ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012252 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved