Skip to content

Commit

Permalink
Indicate white pieces as player one and black as player two
Browse files Browse the repository at this point in the history
Thanks Matt Littlewood!
  • Loading branch information
calcitem committed May 14, 2021
1 parent 7e40f0d commit c2af00c
Show file tree
Hide file tree
Showing 35 changed files with 457 additions and 455 deletions.
12 changes: 6 additions & 6 deletions gamewindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="gamewindow.qrc">:/icon/resources/icon/Black.png</pixmap>
<pixmap resource="gamewindow.qrc">:/icon/resources/icon/White.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand All @@ -462,7 +462,7 @@
</font>
</property>
<property name="text">
<string>Player1 (Black)</string>
<string>Player 1</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -521,7 +521,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="gamewindow.qrc">:/icon/resources/icon/White.png</pixmap>
<pixmap resource="gamewindow.qrc">:/icon/resources/icon/Black.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand All @@ -543,7 +543,7 @@
</font>
</property>
<property name="text">
<string>Player2 (White)</string>
<string>Player 2</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1070,7 +1070,7 @@
</property>
<property name="icon">
<iconset resource="gamewindow.qrc">
<normaloff>:/icon/resources/icon/Black.png</normaloff>:/icon/resources/icon/Black.png</iconset>
<normaloff>:/icon/resources/icon/White.png</normaloff>:/icon/resources/icon/White.png</iconset>
</property>
<property name="text">
<string>AI Moves First</string>
Expand All @@ -1085,7 +1085,7 @@
</property>
<property name="icon">
<iconset resource="gamewindow.qrc">
<normaloff>:/icon/resources/icon/White.png</normaloff>:/icon/resources/icon/White.png</iconset>
<normaloff>:/icon/resources/icon/Black.png</normaloff>:/icon/resources/icon/Black.png</iconset>
</property>
<property name="text">
<string>AI Moves Second</string>
Expand Down
4 changes: 2 additions & 2 deletions millgame-qt_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@
</message>
<message>
<location filename="gamewindow.ui" line="1089"/>
<source>电脑执白(R)</source>
<translation>电脑执白(R)</translation>
<source>电脑执黑(B)</source>
<translation>电脑执黑(B)</translation>
</message>
<message>
<location filename="gamewindow.ui" line="1101"/>
Expand Down
4 changes: 2 additions & 2 deletions programr.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Following is some information about the algorithms and data structures used by S

The mill game board in Sanmill is represented by an array of `24` squares (points), laid out so that square `A1` has the value `8` and square `C8` has the value `31`.

Each square contains `SQ_NONE` if it is empty, or a piece identifier if it is occupied. Black pieces have identifier values between `B_STONE_1` and `B_STONE_12`, while White pieces have values between `W_STONE_1` and `W_STONE_12`. A special value (`BAN_STONE`) is used to represent a square that is banned.
Each square contains `SQ_NONE` if it is empty, or a piece identifier if it is occupied. White pieces have identifier values between `W_STONE_1` and `W_STONE_12`, while Black pieces have values between `B_STONE_1` and `B_STONE_12`. A special value (`BAN_STONE`) is used to represent a square that is banned.

The Board class also maintains several "bit boards" or quantities that that hold 32 bits. The Bitboard class in the source encapsulates a bit board. For example, the occupied bit board has one bit set for every piece that is on the board (there are actually three such bit boards, one for Black, one for White, and one for Ban).
The Board class also maintains several "bit boards" or quantities that that hold 32 bits. The Bitboard class in the source encapsulates a bit board. For example, the occupied bit board has one bit set for every piece that is on the board (there are actually three such bit boards, one for White, one for Black, and one for Ban).

Each type of piece has its own bit board that has one bit set for each piece of that type (for example, there is a `byTypeBB[BAN]` Bitboard to hold ban locations).

Expand Down
2 changes: 1 addition & 1 deletion src/endgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ static const int SAVE_ENDGAME_EVERY_N_GAMES = 256;
enum class EndGameType : uint32_t
{
none,
blackWin,
whiteWin,
blackWin,
draw,
};

Expand Down
32 changes: 16 additions & 16 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ Value Evaluation::value()

int pieceInHandDiffCount;
int pieceOnBoardDiffCount;
int pieceToRemoveCount = (pos.side_to_move() == BLACK) ?
int pieceToRemoveCount = (pos.side_to_move() == WHITE) ?
pos.piece_to_remove_count() : -pos.piece_to_remove_count();;

switch (pos.get_phase()) {
case Phase::ready:
break;

case Phase::placing:
pieceInHandDiffCount = pos.piece_in_hand_count(BLACK) - pos.piece_in_hand_count(WHITE);
pieceInHandDiffCount = pos.piece_in_hand_count(WHITE) - pos.piece_in_hand_count(BLACK);
value += VALUE_EACH_PIECE_INHAND * pieceInHandDiffCount;

pieceOnBoardDiffCount = pos.piece_on_board_count(BLACK) - pos.piece_on_board_count(WHITE);
pieceOnBoardDiffCount = pos.piece_on_board_count(WHITE) - pos.piece_on_board_count(BLACK);
value += VALUE_EACH_PIECE_ONBOARD * pieceOnBoardDiffCount;

switch (pos.get_action()) {
Expand All @@ -77,7 +77,7 @@ Value Evaluation::value()
break;

case Phase::moving:
value = (pos.piece_on_board_count(BLACK) - pos.piece_on_board_count(WHITE)) * VALUE_EACH_PIECE_ONBOARD;
value = (pos.piece_on_board_count(WHITE) - pos.piece_on_board_count(BLACK)) * VALUE_EACH_PIECE_ONBOARD;

#ifdef EVALUATE_MOBILITY
value += pos.get_mobility_diff() / 5;
Expand All @@ -98,21 +98,21 @@ Value Evaluation::value()
break;

case Phase::gameOver:
if (pos.piece_on_board_count(BLACK) + pos.piece_on_board_count(WHITE) >= EFFECTIVE_SQUARE_NB) {
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
if (pos.piece_on_board_count(WHITE) + pos.piece_on_board_count(BLACK) >= EFFECTIVE_SQUARE_NB) {
if (rule.isWhiteLoseButNotDrawWhenBoardFull) {
value -= VALUE_MATE;
} else {
value = VALUE_DRAW;
}
} else if (pos.get_action() == Action::select &&
pos.is_all_surrounded(pos.side_to_move()) &&
rule.isLoseButNotChangeSideWhenNoWay) {
const Value delta = pos.side_to_move() == BLACK ? -VALUE_MATE : VALUE_MATE;
const Value delta = pos.side_to_move() == WHITE ? -VALUE_MATE : VALUE_MATE;
value += delta;
}
else if (pos.piece_on_board_count(BLACK) < rule.piecesAtLeastCount) {
else if (pos.piece_on_board_count(WHITE) < rule.piecesAtLeastCount) {
value -= VALUE_MATE;
} else if (pos.piece_on_board_count(WHITE) < rule.piecesAtLeastCount) {
} else if (pos.piece_on_board_count(BLACK) < rule.piecesAtLeastCount) {
value += VALUE_MATE;
}

Expand All @@ -122,25 +122,25 @@ Value Evaluation::value()
break;
}

if (pos.side_to_move() == WHITE) {
if (pos.side_to_move() == BLACK) {
value = -value;
}

#if EVAL_DRAW_WHEN_NOT_KNOWN_WIN_IF_MAY_FLY
if (pos.get_phase() == Phase::moving && rule.mayFly && !rule.hasDiagonalLines) {
int piece_on_board_count_future_black = pos.piece_on_board_count(BLACK);
int piece_on_board_count_future_white = pos.piece_on_board_count(WHITE);

if (pos.side_to_move() == BLACK) {
piece_on_board_count_future_white -= pos.piece_to_remove_count();
}
int piece_on_board_count_future_black = pos.piece_on_board_count(BLACK);

if (pos.side_to_move() == WHITE) {
piece_on_board_count_future_black -= pos.piece_to_remove_count();
}

if (pos.side_to_move() == BLACK) {
piece_on_board_count_future_white -= pos.piece_to_remove_count();
}


if (piece_on_board_count_future_white == 3 || piece_on_board_count_future_black == 3) {
if (piece_on_board_count_future_black == 3 || piece_on_board_count_future_white == 3) {
if (abs(value) < VALUE_KNOWN_WIN) {
value = VALUE_DRAW;
}
Expand Down
6 changes: 3 additions & 3 deletions src/mills.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Depth get_search_depth(const Position *pos)
constexpr Depth flyingDepth = 9;

if (pos->phase == Phase::placing) {
const int index = rule.piecesCount * 2 - pos->count<IN_HAND>(BLACK) - pos->count<IN_HAND>(WHITE);
const int index = rule.piecesCount * 2 - pos->count<IN_HAND>(WHITE) - pos->count<IN_HAND>(BLACK);

if (rule.piecesCount == 12) {
assert(0 <= index && index <= 24);
Expand All @@ -508,8 +508,8 @@ Depth get_search_depth(const Position *pos)
}

if (pos->phase == Phase::moving) {
const int pb = pos->count<ON_BOARD>(BLACK);
const int pw = pos->count<ON_BOARD>(WHITE);
const int pb = pos->count<ON_BOARD>(WHITE);
const int pw = pos->count<ON_BOARD>(BLACK);

const int pieces = pb + pw;
int diff = pb - pw;
Expand Down
4 changes: 2 additions & 2 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void MovePicker::score()

//cur->value += bannedCount; // placing phrase, place nearby ban point

// for 12 men's morris (has diagonal), white 2nd move place star point is as important as close mill (TODO)
// for 12 men's morris (has diagonal), black 2nd move place star point is as important as close mill (TODO)
if (rule.hasDiagonalLines &&
pos.count<ON_BOARD>(WHITE) < 2 && // patch: only when white 2nd move
pos.count<ON_BOARD>(BLACK) < 2 && // patch: only when black 2nd move
Position::is_star_square(static_cast<Square>(m))) {
cur->value += RATING_STAR_SQUARE;
}
Expand Down
Loading

0 comments on commit c2af00c

Please sign in to comment.