--- fuseki.orig.c 2005-01-25 11:57:33.000000000 +0000 +++ fuseki.c 2005-01-27 17:49:44.000000000 +0000 @@ -112,48 +112,130 @@ {3, 5}, {5, 4}, {4, 5}, + {2, 3}, + {3, 2}, + {2, 2}, + {6, 6}, + {0, 0}, /* center */ }; /* Relative weights for different corner moves at different board sizes. */ -/* up to 11x11 */ -static int small_board[] = +/* up to 8x8 */ /* i don't like 4th line on tiny boards, prefer 2nd line and vital points in the corner */ + /* 40 % move have at least one coordinate on line 4 + * 84 % move line 3 + * 25 % line 2 + * 1% on center + */ +static int tiny_board[] = { - 50, /* 3-3 */ - 18, /* 3-4 */ - 17, /* 4-3 */ - 15, /* 4-4 */ + 24, /* 3-3 */ + 20, /* 3-4 */ + 20, /* 4-3 */ + 0, /* 4-4 */ 0, /* 5-3 */ 0, /* 3-5 */ 0, /* 5-4 */ 0, /* 4-5 */ + 10, /* 2-3 */ + 10, /* 3-2 */ + 5, /* 2-2 */ + 0, /* 6-6 */ + 1, /* 0-0 = Center */ /* I don't like it on small boards : + * - it is boring ;) always the same game + * - maybe it is a weird invisible damezumari ? + * - it breaks no symetries, and W can win with the komi and symetries + * B has sente and it is big enough for not playing center + * => lets consider it is clever strategy not playing it :) + */ + }; -/* 12x12 to 15x15 */ -static int medium_board[] = +/* 9x9 to 11x11 */ /* i dislike the 4x4 point and the center on small boards */ + /* 10 % have a coordinate on line 5 + * 65 % on line 4 + * 80 % on line 3 + * 1 % center + */ +static int small_board[] = { - 30, /* 3-3 */ + 20, /* 3-3 */ 20, /* 3-4 */ 20, /* 4-3 */ - 22, /* 4-4 */ - 2, /* 5-3 */ - 2, /* 3-5 */ - 2, /* 5-4 */ - 2, /* 4-5 */ + 15, /* 4-4 */ + 10, /* 5-3 */ + 10, /* 3-5 */ + 5, /* 5-4 */ + 5, /* 4-5 */ + 0, /* 6-6 */ + 0, /* 2-3 */ + 0, /* 3-2 */ + 0, /* 2-2 */ + 1, /* Center */ }; -/* 16x16 and larger */ +/* 12x12 to 15x15 */ + /* 4 % should be on line 6, + * but this move is never played. probably considered as bad move ;) + * 16 % have a coordinate on line 5 + * 62 % on line 4 + * 66 % on line 3 + * 4% center + */ +static int medium_board[] = +{ + 22, /* 3-3 */ + 18, /* 3-4 */ + 18, /* 4-3 */ + 18, /* 4-4 */ + 4, /* 5-3 */ + 4, /* 3-5 */ + 4, /* 5-4 */ + 4, /* 4-5 */ + 4, /* 6-6 */ + 0, /* 2-3 */ + 0, /* 3-2 */ + 0, /* 2-2 */ + 4, /* Center */ +}; + +/* 16x16 and larger */ /* - ?? Are hoshi/sansan/tengen good because we make less global mistakes + * when playing them , compared with asymetrical random corner occupation. ?? + */ + + /* 6 line not played. + * 22 % move are on line 5 + * 54 % on line 4 + * 42 % on line 3 + * 10 % center + */ static int large_board[] = { - 15, /* 3-3 */ - 15, /* 3-4 */ - 15, /* 4-3 */ - 35, /* 4-4 */ + 12, /* 3-3 */ + 10, /* 3-4 */ + 10, /* 4-3 */ + 20, /* 4-4 */ 5, /* 5-3 */ 5, /* 3-5 */ - 5, /* 5-4 */ - 5, /* 4-5 */ + 6, /* 5-4 */ + 6, /* 4-5 */ + 6, /* 6-6 */ /* Never played, i dont know why. probably estimated as a bad move. that s not false :) + * + * Fuseki.c will consider this point occupy a corner, not the center, thats not false :) + * - In fact it threaten to enclose a corner invader, and allow to choose the side. + * - it works with 2 borders and the center. + * - it works fine when played in 2 or even 3 corners ! + * - it is not as bad as we could think, but need a good global sense and attack strategy so + * it will probably lead to weird things for Gnugo ;) let's see. + */ + 0, /* 2-3 */ + 0, /* 3-2 */ + 0, /* 2-2 */ + 10, /* Center */ /* for the moment Tengen only */ + /*. todo: a "tobi in the center" for even game , and attack everywhere like P.Colmez (~5d) + * sometimes the oponent will prevent the tobi by playing there, and a small fight + * in the center can occur ! */ }; static void @@ -164,18 +246,20 @@ int i; int q; - if (board_size <= 11) + if (board_size <= 8) + table = tiny_board; + else if (board_size <= 11) table = small_board; else if (board_size <= 15) table = medium_board; else table = large_board; - for (i = 0; i < 8; i++) + for (i = 0; i < 13; i++) /* possible move in the corner */ sum_of_weights += table[i]; q = gg_rand() % sum_of_weights; - for (i = 0; i < 8; i++) { + for (i = 0; i < 13; i++) { q -= table[i]; if (q < 0) break; @@ -184,6 +268,12 @@ *m = corners[i][0]; *n = corners[i][1]; + if ( *m == 0 ) { + /* center */ + *m = (board_size+1)/2; + *n = *m; + } + switch (corner) { case UPPER_LEFT: *m = *m - 1; @@ -336,6 +426,12 @@ int width; /* Side of the open region required in the corner. */ int empty_corner_value = EMPTY_CORNER_VALUE * board_size/19; + /* On 9x9, only play open corners after the first move if nothing + * else useful is found. + */ + if (board_size <= 9 && stones_on_board(color) > 0) + empty_corner_value = 5; /* define above as 25*9/19=11 by default */ + /* Return immediately if --disable_fuseki option used. */ if (disable_fuseki) return; @@ -346,30 +442,21 @@ if (fusekidb && search_fuseki_database(color)) return; - /* On 9x9, only play open corners after the first move if nothing - * else useful is found. - */ - if (board_size == 9 && stones_on_board(color) > 0) - empty_corner_value = 5; - - if (board_size <= 11) { - /* For boards of size 11x11 or smaller we first go for the center point. */ - int middle = board_size/2; - if (openregion(middle-2, middle+2, middle-2, middle+2)) { - announce_move(POS(middle, middle), 45, color); - } - } - - if (board_size < 9) - return; - - if (board_size >= 18) - width = 8; + if (board_size <= 8) + width = (board_size-1)/2; /* the median are not part of the width, so sometime a corner is seen as free + when there is a stone on the median line, and that generate a dumb move ! + We just don't care it's on tiny board, we will sometime stupidly lose one game, + but that's the price for easily having diversity on tiny boards, and a lot of + things to do for semeai, end-game, and maybe even global considerations :) */ + else if (board_size == 9) width = 5; - else - width = board_size/2; - + else if (board_size >= 18) + width = 8; + else width = board_size/3+2; + + int middle = (board_size +1)/2; + if (openregion(0, width-1, board_size-width, board_size-1)) { choose_corner_move(UPPER_RIGHT, &i, &j); announce_move(POS(i, j), empty_corner_value, color); @@ -389,6 +476,14 @@ choose_corner_move(UPPER_LEFT, &i, &j); announce_move(POS(i, j), empty_corner_value, color); } + + /* Tengen. We use corners tools and consider center is less valuable than the corners. + * That may avoid breaking joseki moves in other corners */ + if (openregion(middle-(width-1)/2, middle-(width-1)/2 , middle+(width-1)/2, middle+(width-1)/2 )) { + choose_corner_move(UPPER_LEFT, &i, &j); + announce_move(POS(i, j), empty_corner_value*2/3, color); + } + } /*