64,646
社区成员
发帖
与我相关
我的任务
分享
建议使用一些工具检测内在泄露的位置,然后再分析原因
你在AI_BestMove_sample里面追踪下 看是不是迭代器里面跑挂的 打印一下迭代器偏移量
妹子?你是在读研吗?读人工智能吗?
int chessmodel::AlphaBeta(int map[10][9],int depth,int alpha,int beta,bool team)
{
int Score = 0;
std::vector<AI_map> *maps;
// 到达水平线,则返回局面评价值
if (depth == 0)
{
qDebug()<<alpha<<"-----"<<beta;
return this->Eveluate(map);
}
//生成对应的所有走法
maps = AIMaps(team,map);
// 逐一走这些走法,并进行递归
for(std::vector<AI_map>::iterator iter = maps->begin();iter != maps->end();++iter)
{
Score = -this->AlphaBeta(iter->map,depth-1,-beta,-alpha,!team);
if(Score > alpha)
{
alpha = Score;
}
if(Score < beta)
{
break;
}
}
delete maps;
return alpha;
}
int max = -MAXNUM;
int Score = 0;
std::vector<AI_map> *maps;
maps = AIMaps(true,map);
for(std::vector<AI_map>::iterator iter = maps->begin();iter != maps->end();++iter)
{
Score = this->AlphaBeta(this->gameMapvac,depth-1,-MAXNUM,MAXNUM,false);
if(Score > max)
{
max = Score;
memcpy(&this->Bestmap,(&iter->map),sizeof(iter->map));
}
}
delete maps;
return true;
valgrind
你确定是在AI_Sample的memcpy()之前崩溃的吗
你确定是在AI_Sample的memcpy()之前崩溃的吗
看你能不能追踪到是在一步段错误的,MAX = -MAXNUM 我有点没看懂, 还有delete和赋nullptr的顺序可以倒置一下