rule: 移除 "九连棋"

所有规则均允许在相同位置相同序号的三连重复提子。
This commit is contained in:
Calcitem 2020-09-29 10:18:09 +08:00
parent e384d99032
commit 8b7786dda9
5 changed files with 44 additions and 96 deletions

View File

@ -1423,23 +1423,7 @@ int Position::add_mills(Square s)
+ (static_cast<uint64_t>(board[idx[2]]) << 8)
+ static_cast<uint64_t>(idx[2]);
if (rule.allowRemovePiecesRepeatedlyWhenCloseSameMill) {
n++;
continue;
}
int im = 0;
for (im = 0; im < millListSize; im++) {
if (mill == millList[im]) {
break;
}
}
if (im == millListSize) {
n++;
millList[i] = mill;
millListSize++;
}
n++;
}
return n;
@ -1600,22 +1584,21 @@ void Position::mirror(vector <string> &cmdlist, bool cmdChange /*= true*/)
currentSquare = static_cast<Square>(f * RANK_NB + r);
}
if (rule.allowRemovePiecesRepeatedlyWhenCloseSameMill) {
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
r = (RANK_NB - r) % RANK_NB;
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
r = (RANK_NB - r) % RANK_NB;
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
}
if (cmdChange) {
@ -1721,27 +1704,25 @@ void Position::turn(vector <string> &cmdlist, bool cmdChange /*= true*/)
currentSquare = static_cast<Square>(f * RANK_NB + r);
}
if (rule.allowRemovePiecesRepeatedlyWhenCloseSameMill) {
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
if (f == 1)
f = FILE_NB;
else if (f == FILE_NB)
f = 1;
if (f == 1)
f = FILE_NB;
else if (f == FILE_NB)
f = 1;
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
}
// 命令行解析
@ -1908,22 +1889,20 @@ void Position::rotate(vector <string> &cmdlist, int degrees, bool cmdChange /*=
currentSquare = static_cast<Square>(f * RANK_NB + r);
}
if (rule.allowRemovePiecesRepeatedlyWhenCloseSameMill) {
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
for (auto &mill : millList) {
llp[0] = (mill & 0x000000ff00000000) >> 32;
llp[1] = (mill & 0x0000000000ff0000) >> 16;
llp[2] = (mill & 0x00000000000000ff);
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
r = (r + RANK_NB - degrees) % RANK_NB;
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
for (i = 0; i < 3; i++) {
f = static_cast<int>(llp[i]) / RANK_NB;
r = static_cast<int>(llp[i]) % RANK_NB;
r = (r + RANK_NB - degrees) % RANK_NB;
llp[i] = static_cast<uint64_t>(f * RANK_NB + r);
}
mill &= 0xffffff00ff00ff00;
mill |= (llp[0] << 32) | (llp[1] << 16) | llp[2];
}
if (cmdChange) {

View File

@ -91,8 +91,8 @@ public:
void do_move(Move m, StateInfo &newSt);
void undo_move(Move m);
void undo_move(Sanmill::Stack<Position> &ss);
void undo_null_move();
void do_null_move();
void undo_null_move();
// Accessing hash keys
Key key() const;

View File

@ -38,7 +38,6 @@ const struct Rule RULES[N_RULES] = {
false, // 没有斜线
false, // 没有禁点,摆棋阶段被提子的点可以再摆子
false, // 先摆棋者先行棋
true, // 可以重复成三
false, // 多个“三连”只能提一子
false, // 不能提对手的“三连”子,除非无子可提;
true, // 摆棋满子闷棋只有12子棋才出现算先手负
@ -60,7 +59,6 @@ const struct Rule RULES[N_RULES] = {
true, // 有斜线
true, // 有禁点,摆棋阶段被提子的点不能再摆子
true, // 后摆棋者先行棋
true, // 可以重复成三
false, // 多个“三连”只能提一子
true, // 可以提对手的“三连”子
true, // 摆棋满子闷棋只有12子棋才出现算先手负
@ -68,26 +66,6 @@ const struct Rule RULES[N_RULES] = {
false, // 剩三子时不可以飞棋
50 // 50步
},
{
"九连棋", // 九连棋
// 规则说明
"1. 规则与成三棋基本相同,只是它的棋子有序号,\n"
"2. 相同序号、位置的“三连”不能重复提子;\n"
"3. 走棋阶段不能行动(被“闷”),则由对手继续走棋;\n"
"4. 一步出现几个“三连”就可以提几个子。",
9, // 双方各9子
3, // 赛点子数为3
false, // 没有斜线
false, // 没有禁点,摆棋阶段被提子的点可以再摆子
false, // 先摆棋者先行棋
false, // 不可以重复成三
true, // 出现几个“三连”就可以提几个子
false, // 不能提对手的“三连”子,除非无子可提;
true, // 摆棋满子闷棋只有12子棋才出现算先手负
false, // 走棋阶段不能行动(被“闷”),则由对手继续走棋
false, // 剩三子时不可以飞棋
0 // 不计步数
},
{
"莫里斯九子棋", // 莫里斯九子棋
// 规则说明
@ -97,7 +75,6 @@ const struct Rule RULES[N_RULES] = {
false, // 没有斜线
false, // 没有禁点,摆棋阶段被提子的点可以再摆子
false, // 先摆棋者先行棋
true, // 可以重复成三
false, // 多个“三连”只能提一子
false, // 不能提对手的“三连”子,除非无子可提;
true, // 摆棋满子闷棋只有12子棋才出现算先手负
@ -119,7 +96,6 @@ const struct Rule RULES[N_RULES] = {
true, // 有斜线
false, // 没有禁点,摆棋阶段被提子的点可以再摆子
false, // 先摆棋者先行棋
true, // 可以重复成三
false, // 多个“三连”只能提一子
false, // 不能提对手的“三连”子,除非无子可提;
true, // 摆棋满子闷棋只有12子棋才出现算先手负

View File

@ -31,7 +31,6 @@ struct Rule
bool hasObliqueLines;
bool hasBannedLocations;
bool isDefenderMoveFirst;
bool allowRemovePiecesRepeatedlyWhenCloseSameMill;
bool allowRemoveMultiPiecesWhenCloseMultiMill;
bool allowRemovePieceInMill;
bool isBlackLosebutNotDrawWhenBoardFull;
@ -40,7 +39,7 @@ struct Rule
int maxStepsLedToDraw;
};
#define N_RULES 5
#define N_RULES 4
extern const struct Rule RULES[N_RULES];
extern struct Rule rule;

View File

@ -221,10 +221,7 @@ void GameController::gameReset()
newP->setModel(md);
newP->setPos(scene.pos_p1);
newP->setNum(i + 1);
// 如果重复三连不可用,则显示棋子序号,九连棋专用玩法
if (!(rule.allowRemovePiecesRepeatedlyWhenCloseSameMill))
newP->setShowNum(true);
newP->setShowNum(false);
pieceList.push_back(newP);
scene.addItem(newP);
@ -235,10 +232,7 @@ void GameController::gameReset()
newP->setModel(md);
newP->setPos(scene.pos_p2);
newP->setNum(i + 1);
// 如果重复三连不可用,则显示棋子序号,九连棋专用玩法
if (!(rule.allowRemovePiecesRepeatedlyWhenCloseSameMill))
newP->setShowNum(true);
newP->setShowNum(false);
pieceList.push_back(newP);
scene.addItem(newP);