Skip to content

Commit

Permalink
rewind simple ladder detection and without ko.
Browse files Browse the repository at this point in the history
  • Loading branch information
yssaya committed Sep 20, 2019
1 parent d6ad1cf commit a82dde0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/Ladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,26 +225,29 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {
// if ( n == FastBoard::INVAL ) break;
if ( n != to_move ) continue;
int libs = board.get_liberties(n_vtx);
if ( libs >= 4 ) break;
// if ( libs >= 4 ) break;
if ( libs >= 3 ) 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);
// if ( board.get_state(vtx2) != FastBoard::EMPTY
group = parent;
} else {
// if ( group != parent ) break;
if ( group != parent ) break;
}
}
if ( d == 4 && group != FastBoard::PASS && emp4 <= 2 ) {
// if ( d == 4 && group != FastBoard::PASS && emp4 <= 2 ) {
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());
// myprintf("escape_search 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;
}
}

/*
//
group = FastBoard::PASS;
emp4 = 0;
Expand Down Expand Up @@ -272,6 +275,7 @@ int Ladder::ladder_maybe(const FastState &state, int vertex) {
return CANNOT_ESCAPE;
}
}
*/
/*
OOOOO
OO..O ladder, but escape ok. killing eye.
Expand Down
10 changes: 5 additions & 5 deletions src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ Network::Netresult Network::get_output_internal(
// fill_ladder_planes(state, captures_it, escapes_it, symmetry);
fill_ladder_planes(state, captures_it, escapes_it, 0);
*/
#if 1
#if 0
int del_next_sp = 0;
for (auto i=0; i < NUM_INTERSECTIONS; i++) {
const auto x = i % BOARD_SIZE;
Expand Down Expand Up @@ -934,15 +934,15 @@ Network::Netresult Network::get_output_internal(
const auto sym_idx = symmetry_nn_idx_table[symmetry][idx];
result.policy[sym_idx] = outputs[idx];
int ladder = ladder_map[sym_idx];
if ( ladder ) {
if ( 1 && 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 ) {
if ( 0 && mul!=1.0 ) {
extern size_t s_root_movenum;
auto movenum = state->get_movenum();
// myprintf("s_root_movenum=%d\n",s_root_movenum);
Expand All @@ -953,7 +953,7 @@ Network::Netresult Network::get_output_internal(
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 ) {
fprintf(fp,"[%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);
fprintf(fp,"[%d:%3s:m=%3zu,ko=%3d] %.5f -> %.5f\n",ladder,state->board.move_to_text(vertex).c_str(),movenum ,state->m_komove, result.policy[sym_idx],r);
fclose(fp);
}
}
Expand Down

0 comments on commit a82dde0

Please sign in to comment.