哲学和科学论坛哲学和科学论坛计算机 → 五子棋的估值3


  共有187人关注过本帖平板打印复制链接

主题:五子棋的估值3

帅哥哟,离线,有人找我吗?
xzjxu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:3 积分:96 威望:0 精华:0 注册:2017/12/18 20:01:11
五子棋的估值3  发帖心情 Post By:2017/12/18 20:06:39 [只看该作者]

//对当前算分单位正方向上向负方向搜索跳过空点直到遇到zz棋

                ii = i + 4;

                while(ii >= i){

                    wx1 = wx + wxd * ii; wy1 = wy + wyd * ii;

                    if(qp[wx1][wy1] == zz)

                                          break;

                    ii--;

                }

                ii2 = ii;                //记录正方向的这一坐标

 

 

//计算当前算分单位的棋子数和它内部的空位数

                na = 0; nb = 0;          //初始化棋子数和空位数

                for(j = ii1;j<=ii2;j++){

                    wx1 = wx + wxd * j;wy1 = wy + wyd * j;

                    if(qp[wx1][wy1]== zz)

                        na++;

                    else if(qp[wx1][wy1]==0)

                        nb++;

                }

                            nc=sf(na,nb);           //得到当前算分单位的分值

 

 

 

                     }else if(qp[wx][wy]== 0){   //如果当前点为空位

                            qp[wx][wy]= zz;         //则,假定当前点为zz棋

 

//对当前算分单位负方向上向正方向搜索跳过空点直到遇到zz棋

                            ii = i;

                            while(ii <= i + 4){

                                   wx1 = wx + wxd * ii; wy1 = wy + wyd * ii;

                                   if(qp[wx1][wy1]== zz)

                                          break;

                                   ii++;

                            }

                            ii1 = ii;                //记录负方向的这一点坐标

//对当前算分单位正方向上向负方向搜索跳过空点直到遇到zz棋

                            ii = i + 4;

                            while(ii >= i){

                                   wx1 = wx + wxd * ii; wy1 = wy + wyd * ii;

                                   if(qp[wx1][wy1] == zz)

                                          break;

                                   ii--;

                            }

                            ii2 = ii;                //记录正方向的这一坐标

 

//计算当前算分单位的棋子数和它内部的空位数

                            na = 0;nb = 0;           //初始化棋子数和空位数

                            for(j = ii1;j<=ii2;j++){

                                   wx1 = wx + wxd * j;wy1 = wy + wyd * j;

                                   if(qp[wx1][wy1] == zz)

                                          na++;

                                   else if(qp[wx1][wy1]== 0)

                                          nb++;

                            }

                            nc=sf(na,nb);           //得到当前算分单位的分值

 

 

 

                            qp[wx][wy] = 0;         //恢复当前点为空位         

                     }

            nn1 = nn1 + nc;             //各算分单位的分值相加求和

        }

        fxone1 = nn1;

    }

       return fxone1;

}

//根据一个算分单位的子数和空位数计算分值

signed long int sf(short na,short nb){

       signed long int nc;

       switch(na){

              case 1:

                     nc = 0;

                     break;

              case 2:

                     if(nb<2)

                            nc=8;

                     else

                            nc = 8 - 3*(nb-1);

                     break;

              case 3:

                     if(nb<2)

                            nc=32;

                     else

                            nc =32-12 *(nb-1);

                     break;

              case 4:

                     nc = 128;       

                     break;

              case 5:

                     nc = 1024;

                     break;

       }

return nc;

}

2.4  估值的引用方法

在α-β修剪法里,选择下一步的候选点时,根据每个没有子的点的黑白分值之和的大小来选择最有可能的点。计算盘面估值时,计算所有的白子的分值的和和黑子的分值的和之差为盘面的估值。

3         结束语

当然,从估值数据的精确度上,和估值算法上都有改进的余地,包括搜素算法上也有改进的的余地,比如:搜索深度和宽度自适应变化等,都有余地。

 


  单帖管理 | 引用 | 回复 回到顶部

返回版面帖子列表

五子棋的估值3








签名