[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] escape values patch
From: |
Paul Pogonyshev |
Subject: |
[gnugo-devel] escape values patch |
Date: |
06 Nov 2003 19:17:01 +0000 |
Consider this code snippet from compute_owl_escape_values():
else if (dragon[pos].crude_status == UNKNOWN
&& (DRAGON2(pos).escape_route > 5
|| DRAGON2(pos).moyo_size > 5))
owl->escape_values[pos] = 4;
In owl1:319 we have the following position:
A B C D E F G H J K L M N O P Q R S T
19 . . . . . . . . O X X . X X X X . . . 19
18 . . . . . . . O . O X X X O O O X . . 18
17 O O O O . . . . . O X X O O O O X . . 17
16 X X X O . O . . . O X O O O X X O X . 16
15 X . X X O . . . . O O X . O X X . . . 15
14 O X . X O . . . X . . . . O O X . . . 14
13 . X . X O O O O X O O . . O X . . . . 13
12 . . . X X X X O O X O O O X . X . X . 12
11 . . . X O X . X X X X O X . . . . X O 11
10 . . X X O O X X X O X X . X . X X O . 10
9 . . X O . . O O X O O X X . . X O O . 9
8 . . X O . O O O O O O X O . . O . . . 8
7 . . X O . O X O X X X O O O . O . O . 7
6 . . X O . O X X . . . X X O X . O . . 6
5 X X X X O O X . X X X . X O X . . X . 5
4 O X O O . O O X X O X X . X X X X X X 4
3 O O O . . O . O O O X X X O X O O O X 3
2 . . . . . . . . O . O X X O O O . O O 2
1 . . . . . . . . . O O O X O . . . O . 1
A B C D E F G H J K L M N O P Q R S T
The dragon at N8 has large escape route because it can escape to S10
dragon. Because of this, escape values on N8 dragons are equal to 4
during owl reading on S10 dragon. This causes S10 to have escape live
reasons very early and clearly incorrectly.
This patch revises compute_owl_escape_values() to solve this problem.
The logic is like this: "if dragon B has large escape route only
because it can escape to dragon A, then don't consider dragon B a good
escape target for dragon A". This only applies when the crude status
of dragon B is UNKNOWN and it's moyo size is not greater than 5.
The fix also required some quite trivial changes in `influence.c' and
`dragon.c'.
There is no regression breakage. However, there is a major impovement
in the targeted position (owl1:319). The result of `owl_attack S10'
is now `1 T8' instead of `0'. The remaining problem has nothing to do
with escape values.
The patch causes a negligible (less than 0.1%) increase in owl node
counters:
before: 1512058690 2466393 8795545
after: 1512155669 2467554 8795393
The regressions are on top of 3.5.2-pre-1
Paul
--- engine/dragon.c.~1.123.~ 2003-08-13 00:11:40.000000000 +0000
+++ engine/dragon.c 2003-11-05 22:33:14.000000000 +0000
@@ -1867,7 +1867,7 @@ compute_escape(int pos, int dragon_statu
* area (2) or EMPTY (1). Values may change without notice.
*/
get_lively_stones(OTHER_COLOR(board[pos]), safe_stones);
- compute_escape_influence(board[pos], safe_stones, 0, escape_value);
+ compute_escape_influence(board[pos], safe_stones, NULL, 0, escape_value);
/* If we can reach a live group, award 6 points. */
for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
--- engine/influence.c.~1.95.~ 2003-08-13 00:18:36.000000000 +0000
+++ engine/influence.c 2003-11-05 18:45:04.000000000 +0000
@@ -1093,6 +1093,7 @@ find_influence_patterns(struct influence
*/
static void
do_compute_influence(int color, const char safe_stones[BOARDMAX],
+ const char inhibited_sources[BOARDMAX],
const float strength[BOARDMAX], struct influence_data *q,
int move, const char *trace_message)
{
@@ -1107,7 +1108,7 @@ do_compute_influence(int color, const ch
modify_depth_values(1 - stackp);
for (ii = BOARDMIN; ii < BOARDMAX; ii++)
- if (ON_BOARD(ii)) {
+ if (ON_BOARD(ii) && !(inhibited_sources && inhibited_sources[ii])) {
if (q->white_strength[ii] > 0.0)
accumulate_influence(q, ii, WHITE);
if (q->black_strength[ii] > 0.0)
@@ -1164,7 +1165,8 @@ compute_influence(int color, const char
influence_id++;
q->id = influence_id;
- do_compute_influence(color, safe_stones, strength, q, move, trace_message);
+ do_compute_influence(color, safe_stones, NULL, strength,
+ q, move, trace_message);
debug = save_debug;
}
@@ -1765,6 +1767,7 @@ compute_followup_influence(const struct
void
compute_escape_influence(int color, const char safe_stones[BOARDMAX],
+ const char goal[BOARDMAX],
const float strength[BOARDMAX],
char escape_value[BOARDMAX])
{
@@ -1780,33 +1783,35 @@ compute_escape_influence(int color, cons
static char escape_values[BOARDMAX][2];
static int active_caches[2] = {0, 0};
- /* Encode the values of color and dragons_known into an integer
- * between 0 and 3.
- */
int cache_number = (color == WHITE);
- int board_was_cached = 1;
-
- /* Notice that we compare the out of board markers as well, in case
- * the board size should have changed between calls.
- */
- for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
- if (cached_board[ii] != board[ii]) {
- cached_board[ii] = board[ii];
- board_was_cached = 0;
+ if (!goal) {
+ /* Encode the values of color and dragons_known into an integer
+ * between 0 and 3.
+ */
+ int board_was_cached = 1;
+
+ /* Notice that we compare the out of board markers as well, in
+ * case the board size should have changed between calls.
+ */
+ for (ii = BOARDMIN; ii < BOARDMAX; ii++) {
+ if (cached_board[ii] != board[ii]) {
+ cached_board[ii] = board[ii];
+ board_was_cached = 0;
+ }
}
- }
- if (!board_was_cached)
- for (k = 0; k < 2; k++)
- active_caches[k] = 0;
-
- if (active_caches[cache_number]) {
- for (ii = BOARDMIN; ii < BOARDMAX; ii++)
- if (ON_BOARD(ii))
- escape_value[ii] = escape_values[ii][cache_number];
-
- return;
+ if (!board_was_cached)
+ for (k = 0; k < 2; k++)
+ active_caches[k] = 0;
+
+ if (active_caches[cache_number]) {
+ for (ii = BOARDMIN; ii < BOARDMAX; ii++)
+ if (ON_BOARD(ii))
+ escape_value[ii] = escape_values[ii][cache_number];
+
+ return;
+ }
}
/* Use enhance pattern and higher attenuation for escape influence. */
@@ -1819,7 +1824,7 @@ compute_escape_influence(int color, cons
if (!(debug & DEBUG_ESCAPE))
debug &= ~DEBUG_INFLUENCE;
- do_compute_influence(OTHER_COLOR(color), safe_stones, strength,
+ do_compute_influence(OTHER_COLOR(color), safe_stones, goal, strength,
&escape_influence, -1, NULL);
debug = save_debug;
@@ -1827,13 +1832,35 @@ compute_escape_influence(int color, cons
for (ii = BOARDMIN; ii < BOARDMAX; ii++)
if (ON_BOARD(ii)) {
if (whose_moyo(&escape_influence, ii) == color)
- escape_value[ii] = 4;
+ escape_value[ii] = 4;
else if (whose_area(&escape_influence, ii) == color)
- escape_value[ii] = 2;
- else if (whose_area(&escape_influence, ii) == EMPTY)
- escape_value[ii] = 1;
+ escape_value[ii] = 2;
+ else if (whose_area(&escape_influence, ii) == EMPTY) {
+ if (goal) {
+ escape_value[ii] = 0;
+
+ if (!goal[ii]) {
+ int goal_proximity = 0;
+
+ for (k = 0; k < 8; k++) {
+ if (ON_BOARD(ii + delta[k])) {
+ goal_proximity += 2 * goal[ii + delta[k]];
+ if (k < 4 && ON_BOARD(ii + 2 * delta[k]))
+ goal_proximity += goal[ii + delta[k]];
+ }
+ else
+ goal_proximity += 1;
+ }
+
+ if (goal_proximity < 6)
+ escape_value[ii] = 1;
+ }
+ }
+ else
+ escape_value[ii] = 1;
+ }
else
- escape_value[ii] = 0;
+ escape_value[ii] = 0;
}
if (0 && (debug & DEBUG_ESCAPE) && verbose > 0) {
@@ -1845,11 +1872,13 @@ compute_escape_influence(int color, cons
"%3.0f", 3, 1, 1);
}
- /* Save the computed values in the cache. */
- for (ii = BOARDMIN; ii < BOARDMAX; ii++)
- if (ON_BOARD(ii))
- escape_values[ii][cache_number] = escape_value[ii];
- active_caches[cache_number] = 1;
+ if (!goal) {
+ /* Save the computed values in the cache. */
+ for (ii = BOARDMIN; ii < BOARDMAX; ii++)
+ if (ON_BOARD(ii))
+ escape_values[ii][cache_number] = escape_value[ii];
+ active_caches[cache_number] = 1;
+ }
}
--- engine/liberty.h.~1.202.~ 2003-09-09 00:00:57.000000000 +0000
+++ engine/liberty.h 2003-11-05 17:44:53.000000000 +0000
@@ -572,6 +572,7 @@ void compute_followup_influence(const st
struct influence_data *q,
int move, const char *trace_message);
void compute_escape_influence(int color, const char safe_stones[BOARDMAX],
+ const char goal[BOARDMAX],
const float strength[BOARDMAX],
char escape_value[BOARDMAX]);
--- engine/owl.c.~1.179.~ 2003-10-22 02:55:54.000000000 +0000
+++ engine/owl.c 2003-11-06 14:19:47.000000000 +0000
@@ -5236,19 +5265,40 @@ compute_owl_escape_values(struct local_o
char safe_stones[BOARDMAX];
get_lively_stones(OTHER_COLOR(owl->color), safe_stones);
- compute_escape_influence(owl->color, safe_stones, NULL, owl->escape_values);
- DEBUG(DEBUG_ESCAPE, "Owl escape values:\n");
+ compute_escape_influence(owl->color, safe_stones, NULL, NULL,
+ owl->escape_values);
+ DEBUG(DEBUG_ESCAPE, "Owl escape values:\n");
for (m = 0; m < board_size; m++) {
for (n = 0; n < board_size; n++) {
pos = POS(m, n);
- if (dragon[pos].color == owl->color) {
+ if (dragon[pos].color == owl->color && !owl->goal[pos]) {
if (dragon[pos].crude_status == ALIVE)
owl->escape_values[pos] = 6;
- else if (dragon[pos].crude_status == UNKNOWN
- && (DRAGON2(pos).escape_route > 5
- || DRAGON2(pos).moyo_size > 5))
- owl->escape_values[pos] = 4;
+ else if (dragon[pos].crude_status == UNKNOWN) {
+ if (DRAGON2(pos).moyo_size > 5)
+ owl->escape_values[pos] = 4;
+ else if (DRAGON2(pos).escape_route > 5) {
+ if (pos != DRAGON2(pos).origin)
+ owl->escape_values[pos] = owl->escape_values[DRAGON2(pos).origin];
+ else {
+ int pos2;
+ char escape_values[BOARDMAX];
+ char dragon[BOARDMAX];
+
+ compute_escape_influence(owl->color, safe_stones, owl->goal, NULL,
+ escape_values);
+
+ for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++) {
+ if (ON_BOARD(pos2))
+ dragon[pos2] = is_same_dragon(pos2, pos);
+ }
+
+ if (dragon_escape(dragon, owl->color, escape_values) > 5)
+ owl->escape_values[pos] = 4;
+ }
+ }
+ }
}
DEBUG(DEBUG_ESCAPE, "%o%d", owl->escape_values[pos]);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] escape values patch,
Paul Pogonyshev <=