北冥有鱼~~ 2022-10-15 23:01 采纳率: 50%
浏览 27
已结题

博弈树,set集合的使用

写博弈树时,set变量出现访问冲突
#include

#include<stdbool.h>
#include
#include
#include
#include <string.h>
#include
#include
#include<limits.h>
using namespace std;
char board[15][15];
typedef struct cell {
int cx;
int cy;
struct cell* father;
set<struct cell*>child;
char input[15][15];
int x[15][15];//标记横向是否访问过
int y[15][15];//标记纵向
int z[15][15];//标记主对角线
int h[15][15];//标记次对角线
int depth;
int value;
}cell;
cell* root, * nextnode;
int ex = 1;
int maxdepth = 2;
deque<cell*>pos_insert;
int evaluate(cell* a);//估值函数
bool ismax(cell* a);//判断是否为max节点
void f();//对root和nextnode初始化
cell* creat(cell* a, int x, int y);//生成子节点
vector<pair<int, int>>cunchu(cell* a);//把固定下棋区域的节点放入一个容器中
int expand_pos(cell* a);//配合creat生成博弈树
int af_bt(cell* a, int val);//af_bt剪枝(递归)
char qizi(char& s);//判断棋盘上某个节点黑白子或无落子情况
pair<int, int>game();//控制整个游戏
int black(string& s);//某个五元组黑棋的评分
int white(string& s);//某个五元组白棋的评分
void f() {
root = NULL;
root = (cell*)malloc(sizeof(cell));
memcpy(root->input, board, sizeof(board));
root->father = NULL;
root->child.clear();
root->depth = 0;
nextnode = NULL;
}
cell* creat(cell* a, int x, int y) {
cell* node = NULL;
node = (cell*)malloc(sizeof(cell));
node->father = a;
node->child.clear();
node->depth = a->depth + 1;
node->cx = x;
node->cy = y;
memset(node->x, 0, sizeof(node->x));
memset(node->y, 0, sizeof(node->y));
memset(node->z, 0, sizeof(node->z));
memset(node->h, 0, sizeof(node->h));
node->value = INT_MIN;
memcpy(node->input, root->input, sizeof(root->input));
if (ismax(node))
node->input[x][y] = 'w';
else
node->input[x][y] = '1';
return node;
}

调试结果:
while (_Pnext) {//出现读取访问权限冲突
const auto _Pnextptr = static_cast<const_iterator&>(**_Pnext)._Ptr;
if (_Pnextptr == _Myhead || (_Ptr != nullptr && _Pnextptr != _Ptr)) {
_Pnext = &(
_Pnext)->_Mynextiter;
} else { // orphan the iterator
(*_Pnext)->_Myproxy = nullptr;
_Pnext = (_Pnext)->_Mynextiter;
}
}

出现断点,两个初始化函数中的node->child.clear();操作和后续的n->child.insert(m);操作报错
一个实在看不明白,速速快帮帮我
问题怎么回事,怎么解决?
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 10月23日
    • 创建了问题 10月15日

    悬赏问题

    • ¥20 RL+GNN解决人员排班问题时梯度消失
    • ¥15 统计大规模图中的完全子图问题
    • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
    • ¥60 要数控稳压电源测试数据
    • ¥15 能帮我写下这个编程吗
    • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
    • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
    • ¥20 @microsoft/fetch-event-source 流式响应问题
    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式