Skip to content

Commit

Permalink
lib2 captured soon.
Browse files Browse the repository at this point in the history
  • Loading branch information
yssaya committed Sep 19, 2019
1 parent a6495f0 commit d6ad1cf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
40 changes: 34 additions & 6 deletions src/Ladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {

const auto &board = state.board;
const auto to_move = board.get_to_move();
const auto not_to_move = board.get_not_to_move();
// const auto not_to_move = board.get_not_to_move();

if (!state.is_move_legal(to_move, vertex)) {
return NO_LADDER;
Expand All @@ -222,11 +222,11 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {
int n_vtx = board.get_state_neighbor(vertex, d);
int n = board.get_state(n_vtx);
if ( n == FastBoard::EMPTY ) emp4++;
// if ( n == FastBoard::INVAL ) break;
if ( n != to_move ) continue;
int libs = board.get_liberties(n_vtx);
if ( libs >= 3 ) break;
// if ( libs >= 4 ) break;
if ( libs != 1 ) continue;
if ( libs >= 4 ) break;
if ( libs != 1 ) continue;
auto parent = board.m_parent[n_vtx];
if ( group == FastBoard::PASS ) {
// int vtx2 = board.get_state_neighbor(vertex, (d+2)&3);
Expand All @@ -236,7 +236,7 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {
// if ( group != parent ) break;
}
}
if ( d == 4 && emp4 == 2 && group != FastBoard::PASS ) {
if ( d == 4 && group != FastBoard::PASS && emp4 <= 2 ) {
int searched_depth = 0;
bool ret = ladder_escape(state, vertex, &searched_depth);
myprintf("escape_search ret=%d,depth=%d,vtx=%s\n",ret,searched_depth,board.move_to_text(vertex).c_str());
Expand All @@ -245,6 +245,33 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {
}
}

//
group = FastBoard::PASS;
emp4 = 0;
for (d = 0; d < 4; d++) {
int n_vtx = board.get_state_neighbor(vertex, d);
int n = board.get_state(n_vtx);
if ( n == FastBoard::EMPTY ) emp4++;
// if ( n == FastBoard::INVAL ) break;
if ( n != to_move ) continue;
int libs = board.get_liberties(n_vtx);
if ( libs >= 4 ) break;
if ( libs != 2 ) continue;
auto parent = board.m_parent[n_vtx];
if ( group == FastBoard::PASS ) {
group = parent;
} else {
// if ( group != parent ) break;
}
}
if ( d == 4 && group != FastBoard::PASS && emp4 <= 1 ) {
int searched_depth = 0;
bool ret = ladder_escape(state, vertex, &searched_depth, vertex);
myprintf("captured lib2 ret=%d,depth=%d,vtx=%s\n",ret,searched_depth,board.move_to_text(vertex).c_str());
if ( ret == false && searched_depth >= OK_DEPTH ) {
return CANNOT_ESCAPE;
}
}
/*
OOOOO
OO..O ladder, but escape ok. killing eye.
Expand All @@ -257,6 +284,7 @@ OOOOO
..O..XOOXX.
......XXOO.
*/
/*
// find chase not ladder. libs = 2.
group = FastBoard::PASS;
emp4 = 0;
Expand Down Expand Up @@ -288,7 +316,7 @@ OOOOO
return CAPTURE;
}
}

*/
return NO_LADDER;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,19 +937,19 @@ Network::Netresult Network::get_output_internal(
if ( ladder ) {
float r = result.policy[sym_idx];
float mul = 1.0f / 1000000.0f;
// if ( state->m_komove != FastBoard::NO_VERTEX ) mul = 1.0; // ladder escape maybe ok for ko threat.
if ( state->m_komove != FastBoard::NO_VERTEX ) mul = 1.0; // ladder escape maybe ok for ko threat.
if ( ladder == Ladder::CANNOT_CAPTURE ) mul = 1.0f / 1.0f; // 1.0f / 2.0f
if ( ladder == Ladder::CAPTURE ) mul = 1.0; // 1.5

r *= mul;
if ( mul!=1.0 ) {
extern size_t s_root_movenum;
auto movenum = state->get_movenum();
myprintf("s_root_movenum=%d\n",s_root_movenum);
// myprintf("s_root_movenum=%d\n",s_root_movenum);
const auto x = idx % BOARD_SIZE;
const auto y = idx / BOARD_SIZE;
const auto vertex = state->board.get_vertex(y, x);
if ( movenum == s_root_movenum && result.policy[sym_idx] > 0.30 ) {
if ( movenum == s_root_movenum && result.policy[sym_idx] > 0.10 ) {
myprintf("[%d:%3s:m=%3d,ko=%3d] %.5f -> %.5f\n",ladder,state->board.move_to_text(vertex).c_str(),movenum ,state->m_komove, result.policy[sym_idx],r);
FILE *fp = fopen("lz_out.txt","a");
if ( fp ) {
Expand Down

0 comments on commit d6ad1cf

Please sign in to comment.