资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

博弈算法请教

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

各位大大,我在看王小春写的书时,a-b   剪枝发的递归实在想不清楚,希望哪位高人解释一下:  
  int   CAlphaBetaEngine::alphabeta(int   depth,   int   alpha,   int   beta)  
  {  
  int   score;  
  int   Count,i;  
  BYTE   type;  
   
  i   =   IsGameOver(CurPosition,   depth);  
  if   (i   !=   0)  
  return   i;  
   
  if   (depth   <=   0) //叶子节点取估值  
  return   m_pEval->Eveluate(CurPosition,   (m_nMaxDepth-depth)%2);  
   
  Count   =   m_pMG->CreatePossibleMove(CurPosition,   depth,   (m_nMaxDepth-depth)%2);  
   
  for   (i=0;i<Count;i++)    
  {  
   
  type   =   MakeMove(&m_pMG->m_MoveList[depth][i]);  
  score   =   -alphabeta(depth   -   1,   -beta,   -alpha);  
  UnMakeMove(&m_pMG->m_MoveList[depth][i],type);    
   
  if   (score   >   alpha)  
  {  
  alpha   =   score;  
  if(depth   ==   m_nMaxDepth)  
  m_cmBestMove   =   m_pMG->m_MoveList[depth][i];  
  }  
                  if   (alpha   >=   beta)    
                              break;  
   
   
  }  
  return   alpha;  
  }  
   
  语句score   =   -alphabeta(depth   -   1,   -beta,   -alpha);到底时如何实现递归的,对于极大和极小的两种情时如何做到都适用的。  
 

网友回答:

发表者:xiaomin1300

max=-min{-vi}  
  min=-max{-vi}  
  所以两种情况的形式其实是一样的.  
 


 

 
热门推荐笔记本: NETBOOK笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved