写博弈树时,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;
}
}