[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] mixed patch
From: |
Gunnar Farneback |
Subject: |
[gnugo-devel] mixed patch |
Date: |
Sun, 31 Mar 2002 22:42:53 +0200 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode) |
This is a patch with mixed content.
- bugfix in find_connection_moves()
- begin_sgftreedump() can take a NULL pointer parameter
- new gtp command ladder_attack
- joseki tuning
- unneeded include directories removed from sgf/Makefile.*
- cleanup
The joseki tuning adds some variations starting at
--------+
........|
........|
..XOO...|
..XX.O..|
.....X..|
........|
........|
and
---------+
.........|
.........|
.........|
.O..X.O..|
.........|
.........|
.....X...|
.........|
/Gunnar
Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.46
diff -u -r1.46 influence.c
--- engine/influence.c 28 Mar 2002 00:48:31 -0000 1.46
+++ engine/influence.c 31 Mar 2002 19:55:07 -0000
@@ -467,7 +467,7 @@
* already exists an influence source of the respective color at pos
* that is stronger than the new one, we do nothing.
*/
-void
+static void
add_influence_source(int pos, int color, float strength, float attenuation,
struct influence_data *q)
{
Index: engine/matchpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.29
diff -u -r1.29 matchpat.c
--- engine/matchpat.c 30 Mar 2002 20:29:22 -0000 1.29
+++ engine/matchpat.c 31 Mar 2002 19:55:08 -0000
@@ -606,8 +606,8 @@
*/
static void
matchpat_loop(matchpat_callback_fn_ptr callback, int color, int anchor,
- struct pattern_db *pdb, void *callback_data,
- char goal[BOARDMAX], int anchor_in_goal)
+ struct pattern_db *pdb, void *callback_data,
+ char goal[BOARDMAX], int anchor_in_goal)
{
int i, j;
@@ -743,9 +743,9 @@
/* Stub for matchpat function. Work done in recursive helper. */
static void
tree_do_matchpat(int m, int n, matchpat_callback_fn_ptr callback,
- int color, struct pattern_db *database,
- void *callback_data, char goal[BOARDMAX],
- int anchor_in_goal)
+ int color, struct pattern_db *database,
+ void *callback_data, char goal[BOARDMAX],
+ int anchor_in_goal)
{
struct tree_node_list *tree = database->tnl;
struct rec_data data;
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.30
diff -u -r1.30 readconnect.c
--- engine/readconnect.c 25 Mar 2002 21:23:47 -0000 1.30
+++ engine/readconnect.c 31 Mar 2002 19:55:08 -0000
@@ -2084,8 +2084,8 @@
}
if (findlib(str2, 1, &lib) == 1) {
- conn1.distances[lib] = 0;
- conn2.distances[lib] = conn2.distances[str2];
+ conn2.distances[lib] = 0;
+ conn1.distances[lib] = conn1.distances[str2];
}
Index: engine/sgffile.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/sgffile.c,v
retrieving revision 1.14
diff -u -r1.14 sgffile.c
--- engine/sgffile.c 31 Mar 2002 18:48:08 -0000 1.14
+++ engine/sgffile.c 31 Mar 2002 19:55:08 -0000
@@ -367,20 +367,29 @@
* ================================================================ */
-static void
-sgftree_printboard(SGFTree *tree);
+static void sgftree_printboard(SGFTree *tree);
/*
* begin_sgftreedump begins storing all moves considered by
* trymove and tryko in an sgf tree in memory.
+ *
+ * The caller only has to provide an own SGFTree pointer if he wants
+ * to do something more with the tree than writing it to file as done
+ * by end_sgftreedump().
*/
void
begin_sgftreedump(SGFTree *tree)
{
SGFNode *node;
+ static SGFTree local_tree;
gg_assert(sgf_dumptree == NULL);
- sgf_dumptree = tree;
+
+ if (tree == NULL)
+ sgf_dumptree = &local_tree;
+ else
+ sgf_dumptree = tree;
+
sgftree_clear(sgf_dumptree);
node = sgftreeCreateHeaderNode(sgf_dumptree, board_size, 0.0);
sgftreeSetLastNode(sgf_dumptree, node);
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.66
diff -u -r1.66 play_gtp.c
--- interface/play_gtp.c 7 Mar 2002 05:35:28 -0000 1.66
+++ interface/play_gtp.c 31 Mar 2002 19:55:09 -0000
@@ -86,6 +86,7 @@
DECLARE(gtp_increase_depths);
DECLARE(gtp_influence);
DECLARE(gtp_is_legal);
+DECLARE(gtp_ladder_attack);
DECLARE(gtp_list_stones);
DECLARE(gtp_loadsgf);
DECLARE(gtp_name);
@@ -182,6 +183,7 @@
{"is_legal", gtp_is_legal},
{"komi", gtp_set_komi},
{"get_komi", gtp_get_komi},
+ {"ladder_attack", gtp_ladder_attack},
{"level", gtp_set_level},
{"list_stones", gtp_list_stones},
{"loadsgf", gtp_loadsgf},
@@ -880,6 +882,38 @@
}
+/* Function: Try to attack a string strictly in a ladder.
+ * Arguments: vertex
+ * Fails: invalid vertex, empty vertex
+ * Returns: attack code followed by attack point if attack code nonzero.
+ */
+static int
+gtp_ladder_attack(char *s, int id)
+{
+ int i, j;
+ int apos;
+ int attack_code;
+
+ if (!gtp_decode_coord(s, &i, &j))
+ return gtp_failure(id, "invalid coordinate");
+
+ if (BOARD(i, j) == EMPTY)
+ return gtp_failure(id, "vertex must not be empty");
+
+ if (countlib(POS(i, j)) != 2)
+ return gtp_failure(id, "string must have exactly 2 liberties");
+
+ attack_code = simple_ladder(POS(i, j), &apos);
+ gtp_printid(id, GTP_SUCCESS);
+ gtp_print_code(attack_code);
+ if (attack_code > 0) {
+ gtp_printf(" ");
+ gtp_print_vertex(I(apos), J(apos));
+ }
+ return gtp_finish_response();
+}
+
+
/* Function: Increase depth values by one.
* Arguments: none
* Fails: never
@@ -2732,6 +2766,10 @@
*
* Warning: You had better know what you're doing if you try to use this
* command.
+ *
+ * FIXME: We should free the memory from the sgf tree, now that we are
+ * done. This would be simpler if there were an sgftree
+ * function for this. (sgfFreeNode works on an sgfnode.)
*/
static int
gtp_finish_sgftrace(char *s, int id)
Index: patterns/helpers.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/helpers.c,v
retrieving revision 1.33
diff -u -r1.33 helpers.c
--- patterns/helpers.c 30 Mar 2002 20:29:22 -0000 1.33
+++ patterns/helpers.c 31 Mar 2002 19:55:09 -0000
@@ -664,13 +664,13 @@
/*
- * This is identical to connect_and_cut_helper(), except that d is
- * found as a general defense point for A. A is no longer restricted
- * to two liberties.
+ * This is similar to connect_and_cut_helper(), except it starts with
+ * a move at A and that d is found as a general defense point for A. A
+ * is no longer restricted to two liberties.
*
* |.X |dX
- * |XO |AO
- * |XO |Ae
+ * |XO |XO
+ * |.O |Ae
* |.. |bc
*/
Index: patterns/komoku.sgf
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/komoku.sgf,v
retrieving revision 1.5
diff -u -r1.5 komoku.sgf
--- patterns/komoku.sgf 4 Mar 2002 06:49:09 -0000 1.5
+++ patterns/komoku.sgf 31 Mar 2002 19:55:09 -0000
@@ -31,9 +31,16 @@
];B[pc]MA[mf]C[U
]
(;W[nd]MA[lg]C[:-,shape(6)
-];B[qf]MA[mh]C[U
+]PL[B]
+(;B[qf]MA[mh]C[U
];W[jc]C[U
-])
+]MA[if])
+
+(;B[tt]C[
+];W[qe]C[s
+]MA[li];B[re]MA[li];W[pd]MA[li];B[rc]MA[li];W[qf]
+MA[li];B[rf]MA[li];W[qg]MA[li])
+)
(;W[md]MA[jg]C[:-, shape(6)
];B[qf]MA[mh];W[ic]MA[hf])
@@ -96,8 +103,52 @@
)
)
-(;B[ld]MA[ki]C[S];W[of]MA[ki]C[U];B[qf]MA[ki]C[S];W[oh]MA[ki]C[S];
-B[qh]MA[ki]C[S];W[id]MA[ii]C[S])
+(;B[ld]MA[ki]C[S]
+(;W[of]MA[ki]C[U];B[qf]MA[ki]C[S];W[oh]MA[ki]C[S];B[qh]MA[ki]C[S];
+W[id]MA[ii]C[S])
+
+(;W[pg]MA[ki]C[U
+];B[oe]MA[ki]C[U
+];W[ne]MA[ki]C[U
+];B[of]MA[ki]C[U
+];
+W[pd]MA[ki]C[U
+]
+(;B[pe]MA[ki]C[U
+];W[qc]MA[ki];B[qe]MA[ki];W[nc]MA[ki];B[rc]MA[ki];
+W[qb]MA[ki])
+
+(;B[qf]MA[ki]C[U
+]
+(;W[qc]MA[ki];B[qe]MA[ki];W[nc]MA[ki];B[rc]MA[ki];W[qb]MA[ki]
+(;B[qj]MA[kk])
+
+(;B[qk]MA[kl])
+
+(;B[ql]MA[km])
+)
+
+(;W[nf]MA[ki];B[og]MA[ki]C[U
+];W[qc]MA[ki];B[qe]MA[ki]C[U
+]
+(;W[pb]MA[ki]
+(;B[ql]MA[km])
+
+(;B[qk]MA[kl])
+)
+
+(;W[rc]MA[ki]C[0
+# Requires a ladder.
+];B[pi]MA[kj];W[nc]MA[kj])
+)
+
+(;W[pe]MA[ki]C[0
+# Bad
+];B[pf]MA[ki];W[qe]MA[ki];B[nd]MA[ki];W[rf]
+MA[ki];B[rg]MA[ki];W[re]MA[ki];B[qg]MA[ki];W[nc]MA[ki];B[md]MA[ki])
+)
+)
+)
)
(;W[oc]
Index: patterns/mkpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
retrieving revision 1.65
diff -u -r1.65 mkpat.c
--- patterns/mkpat.c 30 Mar 2002 20:29:22 -0000 1.65
+++ patterns/mkpat.c 31 Mar 2002 19:55:09 -0000
@@ -1507,7 +1507,6 @@
}
-/* FIXED: This only needs to be size 2, not 1000 */
struct tree_node graph[2];
int tree_next = 0;
Index: patterns/patterns.db
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.db,v
retrieving revision 1.64
diff -u -r1.64 patterns.db
--- patterns/patterns.db 30 Mar 2002 15:03:16 -0000 1.64
+++ patterns/patterns.db 31 Mar 2002 19:55:10 -0000
@@ -7209,7 +7209,6 @@
> replace(a,*)
-
###############
# Miscellaneous
###############
@@ -8926,7 +8925,7 @@
:8,O,shape(2)
-?Xxd??
+?Xxd??
ocX.e?
obO*a.
......
@@ -10503,7 +10502,7 @@
:8,-,shape(-3)
-oOXx?? don't do this!
+oOXx??
..OAx?
...*.x
.....?
Index: patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.30
diff -u -r1.30 patterns.h
--- patterns/patterns.h 30 Mar 2002 20:29:22 -0000 1.30
+++ patterns/patterns.h 31 Mar 2002 19:55:10 -0000
@@ -358,7 +358,6 @@
/* Tree-based pattern matching structures*/
-/* FIXED: graph_* should be renamed to tree_* */
struct match_node;
struct tree_node_list;
Index: sgf/Makefile.am
===================================================================
RCS file: /cvsroot/gnugo/gnugo/sgf/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- sgf/Makefile.am 29 Mar 2002 15:27:53 -0000 1.5
+++ sgf/Makefile.am 31 Mar 2002 19:55:10 -0000
@@ -12,9 +12,7 @@
DISTCLEANFILES = *~
INCLUDES =\
- -I$(top_srcdir)/engine\
- -I$(top_srcdir)/utils\
- -I$(top_srcdir)/interface
+ -I$(top_srcdir)/utils
noinst_LIBRARIES = libsgf.a
Index: sgf/Makefile.in
===================================================================
RCS file: /cvsroot/gnugo/gnugo/sgf/Makefile.in,v
retrieving revision 1.26
diff -u -r1.26 Makefile.in
--- sgf/Makefile.in 29 Mar 2002 15:27:53 -0000 1.26
+++ sgf/Makefile.in 31 Mar 2002 19:55:10 -0000
@@ -93,9 +93,7 @@
DISTCLEANFILES = *~
INCLUDES = \
- -I$(top_srcdir)/engine\
- -I$(top_srcdir)/utils\
- -I$(top_srcdir)/interface
+ -I$(top_srcdir)/utils
noinst_LIBRARIES = libsgf.a