From e54ec69b1de6cf802056b9b8d84976eec917fe6b Mon Sep 17 00:00:00 2001 From: Calcitem Date: Thu, 31 Dec 2020 21:53:30 +0800 Subject: [PATCH] position: Move create_mill_table() to Mills::mill_table_init() --- src/mills.cpp | 105 +++++++++++++++++++++++++++++++++++++++++++++++ src/mills.h | 1 + src/position.cpp | 102 +-------------------------------------------- 3 files changed, 108 insertions(+), 100 deletions(-) diff --git a/src/mills.cpp b/src/mills.cpp index aa8174cd..48eedc01 100644 --- a/src/mills.cpp +++ b/src/mills.cpp @@ -24,6 +24,7 @@ #include "mills.h" #include "misc.h" #include "option.h" +#include "position.h" namespace Mills { @@ -261,6 +262,110 @@ void adjacent_squares_init() #endif } +void mill_table_init() +{ + const Bitboard millTableBB9[SQUARE_NB][LD_NB] = { + /* 0 */ {0, 0, 0}, + /* 1 */ {0, 0, 0}, + /* 2 */ {0, 0, 0}, + /* 3 */ {0, 0, 0}, + /* 4 */ {0, 0, 0}, + /* 5 */ {0, 0, 0}, + /* 6 */ {0, 0, 0}, + /* 7 */ {0, 0, 0}, + + /* 8 */ {S2(16, 24), S2(9, 15), ~0U}, + /* 9 */ {~0U, S2(15, 8), S2(10, 11)}, + /* 10 */ {S2(18, 26), S2(11, 9), ~0U}, + /* 11 */ {~0U, S2(9, 10), S2(12, 13)}, + /* 12 */ {S2(20, 28), S2(13, 11), ~0U}, + /* 13 */ {~0U, S2(11, 12), S2(14, 15)}, + /* 14 */ {S2(22, 30), S2(15, 13), ~0U}, + /* 15 */ {~0U, S2(13, 14), S2(8, 9)}, + + /* 16 */ {S2(8, 24), S2(17, 23), ~0U}, + /* 17 */ {~0U, S2(23, 16), S2(18, 19)}, + /* 18 */ {S2(10, 26), S2(19, 17), ~0U}, + /* 19 */ {~0U, S2(17, 18), S2(20, 21)}, + /* 20 */ {S2(12, 28), S2(21, 19), ~0U}, + /* 21 */ {~0U, S2(19, 20), S2(22, 23)}, + /* 22 */ {S2(14, 30), S2(23, 21), ~0U}, + /* 23 */ {~0U, S2(21, 22), S2(16, 17)}, + + /* 24 */ {S2(8, 16), S2(25, 31), ~0U}, + /* 25 */ {~0U, S2(31, 24), S2(26, 27)}, + /* 26 */ {S2(10, 18), S2(27, 25), ~0U}, + /* 27 */ {~0U, S2(25, 26), S2(28, 29)}, + /* 28 */ {S2(12, 20), S2(29, 27), ~0U}, + /* 29 */ {~0U, S2(27, 28), S2(30, 31)}, + /* 30 */ {S2(14, 22), S2(31, 29), ~0U}, + /* 31 */ {~0U, S2(29, 30), S2(24, 25)}, + + /* 32 */ {0, 0, 0}, + /* 33 */ {0, 0, 0}, + /* 34 */ {0, 0, 0}, + /* 35 */ {0, 0, 0}, + /* 36 */ {0, 0, 0}, + /* 37 */ {0, 0, 0}, + /* 38 */ {0, 0, 0}, + /* 39 */ {0, 0, 0}, + }; + + const Bitboard millTableBB12[SQUARE_NB][LD_NB] = { + /* 0 */ {0, 0, 0}, + /* 1 */ {0, 0, 0}, + /* 2 */ {0, 0, 0}, + /* 3 */ {0, 0, 0}, + /* 4 */ {0, 0, 0}, + /* 5 */ {0, 0, 0}, + /* 6 */ {0, 0, 0}, + /* 7 */ {0, 0, 0}, + + /* 8 */ {S2(16, 24), S2(9, 15), ~0U}, + /* 9 */ {S2(17, 25), S2(15, 8), S2(10, 11)}, + /* 10 */ {S2(18, 26), S2(11, 9), ~0U}, + /* 11 */ {S2(19, 27), S2(9, 10), S2(12, 13)}, + /* 12 */ {S2(20, 28), S2(13, 11), ~0U}, + /* 13 */ {S2(21, 29), S2(11, 12), S2(14, 15)}, + /* 14 */ {S2(22, 30), S2(15, 13), ~0U}, + /* 15 */ {S2(23, 31), S2(13, 14), S2(8, 9)}, + + /* 16 */ {S2(8, 24), S2(17, 23), ~0U}, + /* 17 */ {S2(9, 25), S2(23, 16), S2(18, 19)}, + /* 18 */ {S2(10, 26), S2(19, 17), ~0U}, + /* 19 */ {S2(11, 27), S2(17, 18), S2(20, 21)}, + /* 20 */ {S2(12, 28), S2(21, 19), ~0U}, + /* 21 */ {S2(13, 29), S2(19, 20), S2(22, 23)}, + /* 22 */ {S2(14, 30), S2(23, 21), ~0U}, + /* 23 */ {S2(15, 31), S2(21, 22), S2(16, 17)}, + + /* 24 */ {S2(8, 16), S2(25, 31), ~0U}, + /* 25 */ {S2(9, 17), S2(31, 24), S2(26, 27)}, + /* 26 */ {S2(10, 18), S2(27, 25), ~0U}, + /* 27 */ {S2(11, 19), S2(25, 26), S2(28, 29)}, + /* 28 */ {S2(12, 20), S2(29, 27), ~0U}, + /* 29 */ {S2(13, 21), S2(27, 28), S2(30, 31)}, + /* 30 */ {S2(14, 22), S2(31, 29), ~0U}, + /* 31 */ {S2(15, 23), S2(29, 30), S2(24, 25)}, + + /* 32 */ {0, 0, 0}, + /* 33 */ {0, 0, 0}, + /* 34 */ {0, 0, 0}, + /* 35 */ {0, 0, 0}, + /* 36 */ {0, 0, 0}, + /* 37 */ {0, 0, 0}, + /* 38 */ {0, 0, 0}, + /* 39 */ {0, 0, 0}, + }; + + // TODO: change to ptr? + if (rule.hasObliqueLines) { + memcpy(Position::millTableBB, millTableBB12, sizeof(Position::millTableBB)); + } else { + memcpy(Position::millTableBB, millTableBB9, sizeof(Position::millTableBB)); + } +} + void move_priority_list_shuffle() { std::array movePriorityList0; diff --git a/src/mills.h b/src/mills.h index 1735b8e6..46baa424 100644 --- a/src/mills.h +++ b/src/mills.h @@ -26,6 +26,7 @@ namespace Mills { void adjacent_squares_init(); +void mill_table_init(); void move_priority_list_shuffle(); } diff --git a/src/position.cpp b/src/position.cpp index 0dcee415..0128142c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -33,6 +33,7 @@ #include "option.h" #include "rule.h" +#include "mills.h" using std::string; @@ -1087,106 +1088,7 @@ Bitboard Position::millTableBB[SQUARE_NB][LD_NB] = {{0}}; void Position::create_mill_table() { - const Bitboard millTableBB9[SQUARE_NB][LD_NB] = { - /* 0 */ {0, 0, 0}, - /* 1 */ {0, 0, 0}, - /* 2 */ {0, 0, 0}, - /* 3 */ {0, 0, 0}, - /* 4 */ {0, 0, 0}, - /* 5 */ {0, 0, 0}, - /* 6 */ {0, 0, 0}, - /* 7 */ {0, 0, 0}, - - /* 8 */ {S2(16, 24), S2(9, 15), ~0U}, - /* 9 */ {~0U, S2(15, 8), S2(10, 11)}, - /* 10 */ {S2(18, 26), S2(11, 9), ~0U}, - /* 11 */ {~0U, S2(9, 10), S2(12, 13)}, - /* 12 */ {S2(20, 28), S2(13, 11), ~0U}, - /* 13 */ {~0U, S2(11, 12), S2(14, 15)}, - /* 14 */ {S2(22, 30), S2(15, 13), ~0U}, - /* 15 */ {~0U, S2(13, 14), S2(8, 9)}, - - /* 16 */ {S2(8, 24), S2(17, 23), ~0U}, - /* 17 */ {~0U, S2(23, 16), S2(18, 19)}, - /* 18 */ {S2(10, 26), S2(19, 17), ~0U}, - /* 19 */ {~0U, S2(17, 18), S2(20, 21)}, - /* 20 */ {S2(12, 28), S2(21, 19), ~0U}, - /* 21 */ {~0U, S2(19, 20), S2(22, 23)}, - /* 22 */ {S2(14, 30), S2(23, 21), ~0U}, - /* 23 */ {~0U, S2(21, 22), S2(16, 17)}, - - /* 24 */ {S2(8, 16), S2(25, 31), ~0U}, - /* 25 */ {~0U, S2(31, 24), S2(26, 27)}, - /* 26 */ {S2(10, 18), S2(27, 25), ~0U}, - /* 27 */ {~0U, S2(25, 26), S2(28, 29)}, - /* 28 */ {S2(12, 20), S2(29, 27), ~0U}, - /* 29 */ {~0U, S2(27, 28), S2(30, 31)}, - /* 30 */ {S2(14, 22), S2(31, 29), ~0U}, - /* 31 */ {~0U, S2(29, 30), S2(24, 25)}, - - /* 32 */ {0, 0, 0}, - /* 33 */ {0, 0, 0}, - /* 34 */ {0, 0, 0}, - /* 35 */ {0, 0, 0}, - /* 36 */ {0, 0, 0}, - /* 37 */ {0, 0, 0}, - /* 38 */ {0, 0, 0}, - /* 39 */ {0, 0, 0}, - }; - - const Bitboard millTableBB12[SQUARE_NB][LD_NB] = { - /* 0 */ {0, 0, 0}, - /* 1 */ {0, 0, 0}, - /* 2 */ {0, 0, 0}, - /* 3 */ {0, 0, 0}, - /* 4 */ {0, 0, 0}, - /* 5 */ {0, 0, 0}, - /* 6 */ {0, 0, 0}, - /* 7 */ {0, 0, 0}, - - /* 8 */ {S2(16, 24), S2(9, 15), ~0U}, - /* 9 */ {S2(17, 25), S2(15, 8), S2(10, 11)}, - /* 10 */ {S2(18, 26), S2(11, 9), ~0U}, - /* 11 */ {S2(19, 27), S2(9, 10), S2(12, 13)}, - /* 12 */ {S2(20, 28), S2(13, 11), ~0U}, - /* 13 */ {S2(21, 29), S2(11, 12), S2(14, 15)}, - /* 14 */ {S2(22, 30), S2(15, 13), ~0U}, - /* 15 */ {S2(23, 31), S2(13, 14), S2(8, 9)}, - - /* 16 */ {S2(8, 24), S2(17, 23), ~0U}, - /* 17 */ {S2(9, 25), S2(23, 16), S2(18, 19)}, - /* 18 */ {S2(10, 26), S2(19, 17), ~0U}, - /* 19 */ {S2(11, 27), S2(17, 18), S2(20, 21)}, - /* 20 */ {S2(12, 28), S2(21, 19), ~0U}, - /* 21 */ {S2(13, 29), S2(19, 20), S2(22, 23)}, - /* 22 */ {S2(14, 30), S2(23, 21), ~0U}, - /* 23 */ {S2(15, 31), S2(21, 22), S2(16, 17)}, - - /* 24 */ {S2(8, 16), S2(25, 31), ~0U}, - /* 25 */ {S2(9, 17), S2(31, 24), S2(26, 27)}, - /* 26 */ {S2(10, 18), S2(27, 25), ~0U}, - /* 27 */ {S2(11, 19), S2(25, 26), S2(28, 29)}, - /* 28 */ {S2(12, 20), S2(29, 27), ~0U}, - /* 29 */ {S2(13, 21), S2(27, 28), S2(30, 31)}, - /* 30 */ {S2(14, 22), S2(31, 29), ~0U}, - /* 31 */ {S2(15, 23), S2(29, 30), S2(24, 25)}, - - /* 32 */ {0, 0, 0}, - /* 33 */ {0, 0, 0}, - /* 34 */ {0, 0, 0}, - /* 35 */ {0, 0, 0}, - /* 36 */ {0, 0, 0}, - /* 37 */ {0, 0, 0}, - /* 38 */ {0, 0, 0}, - /* 39 */ {0, 0, 0}, - }; - - // TODO: change to ptr? - if (rule.hasObliqueLines) { - memcpy(millTableBB, millTableBB12, sizeof(millTableBB)); - } else { - memcpy(millTableBB, millTableBB9, sizeof(millTableBB)); - } + Mills::mill_table_init(); } Color Position::color_on(Square s) const