From 75276915bec3005d267121f36855fe1b8c14d1ef Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 30 Aug 2020 22:16:50 +0800 Subject: [PATCH] =?UTF-8?q?movengen:=20movePriorityTable=20=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=B1=BB=E5=9E=8B=E7=94=B1=20Move=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20Square?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/movegen.cpp | 26 +++++++++++++------------- src/movegen.h | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index b3d70e03..919e195c 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -244,17 +244,17 @@ void MoveList::create() void MoveList::shuffle() { - array movePriorityTable0 = { (Move)17, (Move)19, (Move)21, (Move)23 }; - array movePriorityTable1 = { (Move)25, (Move)27, (Move)29, (Move)31, (Move)9, (Move)11, (Move)13, (Move)15 }; - array movePriorityTable2 = { (Move)16, (Move)18, (Move)20, (Move)22 }; - array movePriorityTable3 = { (Move)24, (Move)26, (Move)28, (Move)30, (Move)8, (Move)10, (Move)12, (Move)14 }; + array movePriorityTable0 = { SQ_17, SQ_19, SQ_21, SQ_23 }; + array movePriorityTable1 = { SQ_25, SQ_27, SQ_29, SQ_31, SQ_9, SQ_11, SQ_13, SQ_15 }; + array movePriorityTable2 = { SQ_16, SQ_18, SQ_20, SQ_22 }; + array movePriorityTable3 = { SQ_24, SQ_26, SQ_28, SQ_30, SQ_8, SQ_10, SQ_12, SQ_14 }; if (rule.nTotalPiecesEachSide == 9) { - movePriorityTable0 = { (Move)16, (Move)18, (Move)20, (Move)22 }; - movePriorityTable1 = { (Move)24, (Move)26, (Move)28, (Move)30, (Move)8, (Move)10, (Move)12, (Move)14 }; - movePriorityTable2 = { (Move)17, (Move)19, (Move)21, (Move)23 }; - movePriorityTable3 = { (Move)25, (Move)27, (Move)29, (Move)31, (Move)9, (Move)11, (Move)13, (Move)15 }; + movePriorityTable0 = { SQ_16, SQ_18, SQ_20, SQ_22 }; + movePriorityTable1 = { SQ_24, SQ_26, SQ_28, SQ_30, SQ_8, SQ_10, SQ_12, SQ_14 }; + movePriorityTable2 = { SQ_17, SQ_19, SQ_21, SQ_23 }; + movePriorityTable3 = { SQ_25, SQ_27, SQ_29, SQ_31, SQ_9, SQ_11, SQ_13, SQ_15 }; } @@ -306,8 +306,8 @@ ExtMove *generate(/* TODO: const */ Position *position, ExtMove *moveList) case ACTION_PLACE: // 对于摆子阶段 if (position->phase & (PHASE_PLACING | PHASE_READY)) { - for (Move i : MoveList::movePriorityTable) { - s = static_cast(i); + for (Square i : MoveList::movePriorityTable) { + s = i; if (position->board[s]) { continue; @@ -337,7 +337,7 @@ ExtMove *generate(/* TODO: const */ Position *position, ExtMove *moveList) // move piece that location weak first for (int i = MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) { - oldSquare = static_cast(MoveList::movePriorityTable[i]); + oldSquare = MoveList::movePriorityTable[i]; if (!position->select_piece(oldSquare)) { continue; @@ -368,7 +368,7 @@ ExtMove *generate(/* TODO: const */ Position *position, ExtMove *moveList) case ACTION_REMOVE: if (position->is_all_in_mills(them)) { for (int i = MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) { - s = static_cast(MoveList::movePriorityTable[i]); + s = MoveList::movePriorityTable[i]; if (position->board[s]& (them << PLAYER_SHIFT)) { *cur++ = ((Move)-s); } @@ -378,7 +378,7 @@ ExtMove *generate(/* TODO: const */ Position *position, ExtMove *moveList) // not is all in mills for (int i = MOVE_PRIORITY_TABLE_SIZE - 1; i >= 0; i--) { - s = static_cast(MoveList::movePriorityTable[i]); + s = MoveList::movePriorityTable[i]; if (position->board[s]& (them << PLAYER_SHIFT)) { if (rule.allowRemovePieceInMill || !position->in_how_many_mills(s, NOBODY)) { *cur++ = ((Move)-s); diff --git a/src/movegen.h b/src/movegen.h index 425ccfee..7bf28530 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -83,10 +83,10 @@ struct MoveList static void create(); static void shuffle(); - inline static std::array movePriorityTable { - (Move) 8, (Move) 9, (Move)10, (Move)11, (Move)12, (Move)13, (Move)14, (Move)15, - (Move)16, (Move)17, (Move)18, (Move)19, (Move)20, (Move)21, (Move)22, (Move)23, - (Move)24, (Move)25, (Move)26, (Move)27, (Move)28, (Move)29, (Move)30, (Move)31, + inline static std::array movePriorityTable { + SQ_8, SQ_9, SQ_10, SQ_11, SQ_12, SQ_13, SQ_14, SQ_15, + SQ_16, SQ_17, SQ_18, SQ_19, SQ_20, SQ_21, SQ_22, SQ_23, + SQ_24, SQ_25, SQ_26, SQ_27, SQ_28, SQ_29, SQ_30, SQ_31, }; inline static Move moveTable[SQUARE_NB][MD_NB] = { {MOVE_NONE} };