typedef struct point
{
int row;
int col;
}point_t;
point_t actionAI(ChessData* data)
{
calcScore(data);
int maxScore = 0;
std::vector<std::pair<int, int> > maxPoints;//容器
int k = 0;
for (int row = 0; row < BOARD_GRAD_SIZE; row++)
{
for (int col = 0; col < BOARD_GRAD_SIZE; col++)
{
if (data->chessMap[row][col] == 0)
{
if (data->scoreMap[row][col] > maxScore)
{
maxPoints.clear();
k = 0;
maxPoints.push_back(std::make_pair(row, col));
k++;
}
else if (data->scoreMap[row][col] == maxScore)
{
maxPoints.push_back(std::make_pair(row, col));
k++;
}
}
}
}
srand((unsigned)time(0));
int index = rand() % k;
return maxPoints[index];
//返回报错,不存在用户定义的从"std::pair<int,int>"到"point_t"的适当转换(point_t是struct结构体的名字)
}
不存在用户定义的从"std::pair<int,int>"到"point_t"的适当转换(point_t是struct结构体的名字)
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- stone_wangzx 2021-12-31 11:41关注
给point添加对应的构造函数试试
typedef struct point { int row; int col; point() {} point(std::pair<int, int> data) { row = data.first; col = data.second; } }point_t;
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统