马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
一、棋型模式分析
构造有'0'和'1'构成的序列,来一一映射棋型如:‘活四’、‘冲三’、‘冲四’、‘活三’、‘活二’、‘冲二’等等。
思索:如何构造这样的序列?
对于一个棋子的得分评估,我是应该用'00001','00010','00100'类似这样的方式来映射吗?
假如以这样的方式对应,当我遇到活二的棋型时,我评估棋局时会出现这样的情况,盘算机有可能会把它当作两个孤立棋子的分数举行评估,即分别对应'00001'和'10000'两个棋型的分数举行相加才是活二的应有的分数。
以是有以下评估棋型的方式,假如我想按棋子数目来分类,并举行棋型分数评估,我以一种对称的方式举行则比较好,五位序列代表冲棋形式,六位代表活四形式。
点击查看代码- //Key-val分值表
- std::vector<Pattern> patterns = {
- { "11111", 50000 },
- { "011110", 4320 },
- { "011100", 720 },
- { "001110", 720 },
- { "011010", 720 },
- { "010110", 720 },
- { "11110", 720 },
- { "01111", 720 },
- { "11011", 720 },
- { "10111", 720 },
- { "11101", 720 },
- { "001100", 120 },
- { "001010", 120 },
- { "010100", 120 },
- { "000100", 20 },
- { "001000", 20 },
- };
复制代码 得分函数:点击查看代码[code]int aiJudge::getScore(bool color, int x, int y, int g[][N]){ int ans = 0; int dir = -1; int nowcolor = color ? 1 : -1; //获取8联通方向的棋子排布 while (++dir < 4) { std::deque S; S.push_back(1); int sign = -1; for (int i = 1; i < 4; ++i) { int tx = x + sign * i * dx[dir], ty = y + sign * i * dy[dir]; if (!posIsLegal(tx, ty)){ S.push_front(2); break; } if (g[tx][ty] == 0) { S.push_front(0); } if (g[tx][ty] == nowcolor) S.push_front(1); if (g[tx][ty] == -nowcolor) { S.push_front(2); break; } } sign = -sign; for (int i = 1; i ACSearch(s); for (int j = 0; j |