int nega_max(int level,int max_depth,int alpha,int beta,last_level_information_t last_level_information){
//初始化临时数据
int val=0;
int best=0;
int score=0;
int parameter_cal_score = -last_level_information.who_big;
int parameter_get_move= -last_level_information.who_go;
//生成ID
QString des;
for(int i=0;i<182;i++){
QString c=QString::number(t_Board[i]);
des+=c;
}
QString md5;
QByteArray bb;
bb = QCryptographicHash::hash ( des.toLatin1(), QCryptographicHash::Md5 );
md5.append(bb.toHex());
//同步棋盘
if(level==max_depth){
for(int i=30;i<152;i++){
t_Board[i]=Board[i];
}
}
//估分
if(level<=0){
return cal_score(parameter_cal_score);
}
last_level_information_t now_level_information={parameter_cal_score,parameter_get_move};
//生成着法表
QVector <possible_t> steps;
get_all_possible_move(steps,parameter_get_move,0,t_Board);
//查询置换表
if(level!=max_depth){
QList<int>values = hash.values(md5);
if(values.size()==1){
return (values.at(0));
}
}
}
//AI常规计算部分
fakemove(steps[0]);
best=-nega_max(level-1,max_depth,-beta,-alpha,now_level_information);
unfakemove(steps[0]);
steps[0].score=best;
if(level==max_depth){
best_move=steps[0];
}
//计算第二个及以后的走法
for(int i=1;i<steps.size();i++){
if(best<beta){
if(best>alpha){
alpha=best;
}
fakemove(steps[i]);
score=-nega_max(level-1,max_depth,-alpha-1,-alpha,now_level_information);
if(score>alpha&&score<beta){
best=-nega_max(level-1,max_depth,-beta,-score,now_level_information);
steps[i].score=best;
if(level==max_depth){
best_move=steps[i];
}
}else if(score>best){
best=score;
if(level==max_depth){
best_move=steps[i];
}
}
unfakemove(steps[i]);
}
}
//置换表未命中
hash.insert(md5,best);//将该节点插入置换表
return best;
}
电脑加了置换表以后,送马送车,不知道怎么回事啊?怎么办啊?