[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] limit_search and restricted_genmove
From: |
Arend Bayer |
Subject: |
[gnugo-devel] limit_search and restricted_genmove |
Date: |
Wed, 1 Feb 2006 00:49:38 +0100 (CET) |
We have two mechanisms to restrict search to a subset of the moves,
limit_search and restricted_genmove. This is not desirable, of course.
I suggest the following patch. It makes limit_search a private variable
of genmove.c. If genmove() finds it is set, do_genmove() is called with
the search_mask as list of allowed moves. Which means the rest of the engine
only has to worry about allowed_moves[].
Dan, since oracle is affected by this, it would be good if you could have
a look.
Arend
Index: engine/genmove.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/genmove.c,v
retrieving revision 1.112
diff -u -p -r1.112 genmove.c
--- engine/genmove.c 25 Jan 2006 17:05:03 -0000 1.112
+++ engine/genmove.c 31 Jan 2006 23:38:16 -0000
@@ -36,6 +36,13 @@
*/
#define NEEDS_UPDATE(x) (x != position_number ? (x = position_number, 1) : 0)
+/* Mark a limited search area. If limit_search != 1, genmove
+ * will only return moves within the area marked by the array
+ * search_mask.
+ */
+static int limit_search = 0;
+static int search_mask[BOARDMAX];
+
static int do_genmove(int color, float pure_threat_value,
int allowed_moves[BOARDMAX], float *value, int *resign);
@@ -237,14 +244,17 @@ genmove(int color, float *value, int *re
#if ORACLE
if (metamachine) {
- move = metamachine_genmove(color, value);
+ move = metamachine_genmove(color, value, limit_search);
gg_assert(stackp == 0);
if (move != PASS_MOVE)
return move;
}
#endif
- move = do_genmove(color, 0.4, NULL, value, resign);
+ if (limit_search)
+ move = do_genmove(color, 0.4, search_mask, value, resign);
+ else
+ move = do_genmove(color, 0.4, NULL, value, resign);
gg_assert(move == PASS_MOVE || ON_BOARD(move));
return move;
@@ -393,8 +403,7 @@ do_genmove(int color, float pure_threat_
time_report(1, "generate move reasons", NO_MOVE, 1.0);
/* Try to find empty corner moves. */
- if (!limit_search)
- fuseki(color);
+ fuseki(color);
gg_assert(stackp == 0);
/* Look for moves to break mirror play by the opponent. */
@@ -404,7 +413,7 @@ do_genmove(int color, float pure_threat_
* dragon dangerous and change its status from DEAD to
* UNKNOWN. Otherwise, pretend there is no thrashing dragon.
*/
- if (!doing_scoring && !limit_search)
+ if (!doing_scoring)
use_thrashing_dragon_heuristics
= revise_thrashing_dragon(color, pessimistic_score, 5.0);
@@ -428,7 +437,7 @@ do_genmove(int color, float pure_threat_
/* If the move value is 6 or lower, we look for endgame patterns too. */
- if (*value <= 6.0 && !disable_endgame_patterns && !limit_search) {
+ if (*value <= 6.0 && !disable_endgame_patterns) {
endgame_shapes(color);
endgame(color);
gg_assert(stackp == 0);
@@ -771,16 +780,14 @@ should_resign(int color, float optimisti
* Mark a limited search area *
\*********************************************************************/
-/* Mark a limited search area. Only affects the engine if the
- * global variable limit_search is nonzero. In this case, genmove
- * will only return moves within the area marked by the array
- * search_mask.
- */
-
-static int search_mask[BOARDMAX];
+/* Activate or deactivate search limit. */
+void
+set_limit_search(int value)
+{
+ limit_search = value;
+}
-/* The following function marks a diamond of radius 6 with center pos.
- */
+/* The following function marks a diamond of radius 6 with center pos. */
void
set_search_diamond(int pos)
@@ -812,7 +819,7 @@ reset_search_mask()
/* marks a single vertex */
void
-set_search_limit(int pos, int value)
+set_search_mask(int pos, int value)
{
search_mask[pos] = value;
}
Index: engine/globals.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/globals.c,v
retrieving revision 1.79
diff -u -p -r1.79 globals.c
--- engine/globals.c 23 Jan 2006 18:15:50 -0000 1.79
+++ engine/globals.c 31 Jan 2006 23:25:09 -0000
@@ -94,7 +94,6 @@ int debug = 0; /* controls
int verbose = 0; /* trace level */
char outfilename[128] = ""; /* output file (-o option) */
int output_flags = OUTPUT_DEFAULT; /* amount of output to outfile */
-int limit_search = 0; /* limit search to a portion of the board */
int metamachine = 0; /* use metamachine_genmove */
int oracle_exists = 0; /* oracle is available for consultation */
int autolevel_on = 0; /* Adjust level in GMP or ASCII mode. */
Index: engine/gnugo.h
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/gnugo.h,v
retrieving revision 1.132
diff -u -p -r1.132 gnugo.h
--- engine/gnugo.h 29 Jan 2006 18:36:59 -0000 1.132
+++ engine/gnugo.h 31 Jan 2006 23:25:22 -0000
@@ -239,7 +239,6 @@ extern int autolevel_on;
extern float potential_moves[BOARDMAX];
-extern int limit_search; /* limit move search to a portion of the board */
extern int oracle_exists; /* oracle is available for consultation */
extern int metamachine; /* use metamachine_genmove */
Index: engine/liberty.h
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/liberty.h,v
retrieving revision 1.252
diff -u -p -r1.252 liberty.h
--- engine/liberty.h 25 Jan 2006 17:14:04 -0000 1.252
+++ engine/liberty.h 31 Jan 2006 23:39:48 -0000
@@ -499,9 +499,10 @@ void owl_analyze_semeai_after_move(int m
int *semeai_result_certain,
int recompute_dragons);
+void set_limit_search(int value);
void set_search_diamond(int pos);
void reset_search_mask(void);
-void set_search_limit(int pos, int value);
+void set_search_mask(int pos, int value);
int oracle_play_move(int pos, int color);
void consult_oracle(int color);
void summon_oracle(void);
Index: engine/move_reasons.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/move_reasons.c,v
retrieving revision 1.133
diff -u -p -r1.133 move_reasons.c
--- engine/move_reasons.c 23 Jan 2006 18:15:50 -0000 1.133
+++ engine/move_reasons.c 31 Jan 2006 23:25:45 -0000
@@ -362,8 +362,6 @@ add_move_reason(int pos, int type, int w
if (stackp == 0) {
ASSERT1(board[pos] == EMPTY, pos);
}
- if (limit_search && !within_search_area(pos))
- return;
for (k = 0; k < MAX_REASONS; k++) {
int r = move[pos].reason[k];
Index: engine/oracle.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/oracle.c,v
retrieving revision 1.18
diff -u -p -r1.18 oracle.c
--- engine/oracle.c 23 Jan 2006 18:15:50 -0000 1.18
+++ engine/oracle.c 31 Jan 2006 23:27:09 -0000
@@ -342,7 +342,7 @@ static int
do_metamachine_genmove(int color, int width, float *value);
int
-metamachine_genmove(int color, float *value)
+metamachine_genmove(int color, float *value, int limit_search)
{
int move;
int pos;
Index: engine/shapes.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/engine/shapes.c,v
retrieving revision 1.53
diff -u -p -r1.53 shapes.c
--- engine/shapes.c 23 Jan 2006 18:15:50 -0000 1.53
+++ engine/shapes.c 31 Jan 2006 23:25:56 -0000
@@ -233,10 +233,6 @@ shapes_callback(int anchor, int color, s
/* Pick up the location of the move */
move = AFFINE_TRANSFORM(pattern->move_offset, ll, anchor);
- /* For restricted search, the pattern must intersect the search area */
- if (limit_search && !within_search_area(move))
- return;
-
/* For some classes of patterns we need to find all dragons present
* in the pattern.
*/
@@ -538,10 +534,6 @@ joseki_callback(int move, int color, str
int your_dragons[MAX_DRAGONS_PER_PATTERN];
int your_ndragons = 0;
- /* For restricted search, the pattern must intersect the search area. */
- if (limit_search && !within_search_area(move))
- return;
-
/* For urgent joseki patterns we need to find all dragons present in the
* pattern since such patterns are assumed to have strategical effect on
* them.
Index: interface/play_gtp.c
===================================================================
RCS file: /home/arend/Go/gnugo-rsync/gnugo/interface/play_gtp.c,v
retrieving revision 1.179
diff -u -p -r1.179 play_gtp.c
--- interface/play_gtp.c 29 Jan 2006 18:36:59 -0000 1.179
+++ interface/play_gtp.c 31 Jan 2006 23:39:19 -0000
@@ -255,7 +255,6 @@ static struct gtp_command commands[] = {
{"last_move", gtp_last_move},
{"level", gtp_set_level},
{"limit_search", gtp_limit_search},
- {"limit_search", gtp_limit_search},
{"list_commands", gtp_list_commands},
{"list_stones", gtp_list_stones},
{"loadsgf", gtp_loadsgf},
@@ -4481,7 +4480,7 @@ gtp_set_search_diamond(char *s)
if (!gtp_decode_coord(s, &i, &j))
return gtp_failure("invalid coordinate");
- limit_search = 1;
+ set_limit_search(1);
set_search_diamond(POS(i, j));
return gtp_success("");
}
@@ -4512,7 +4511,7 @@ gtp_limit_search(char *s)
if (sscanf(s, "%d", &value) < 1)
return gtp_failure("invalid value for search limit");
- limit_search = value;
+ set_limit_search(value);
return gtp_success("");
}
@@ -4527,7 +4526,7 @@ gtp_set_search_limit(char *s)
int i, j;
gtp_decode_coord(s, &i, &j);
- set_search_limit(POS(i, j), 1);
+ set_search_mask(POS(i, j), 1);
return gtp_success("");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] limit_search and restricted_genmove,
Arend Bayer <=