Ticket #132: gunnar_7_10.13b.diff

File gunnar_7_10.13b.diff, 27.0 kB (added by gunnar, 3 years ago)

Same as gunnar_7_10.13 but with improved documentation

  • TODO

    RCS file: /cvsroot/gnugo/gnugo/TODO,v
    retrieving revision 1.19
    diff -u -r1.19 TODO
     
    6161 
    6262 * Make the cache not waste storage on 64 bit systems. 
    6363 
    64  * Implement detection of superko violation in the board code. We 
    65    probably only want this optionally in play_move() and in a variant 
    66    of is_legal(). 
    67  
    6864 * The dragon data is split into two arrays, dragon[] and dragon2[]. 
    6965   The dragon2 array only have one entry per dragon, in contrast to 
    7066   the dragon array where all the data is stored once for every 
  • doc/introduction.texi

    RCS file: /cvsroot/gnugo/gnugo/doc/introduction.texi,v
    retrieving revision 1.29
    diff -u -r1.29 introduction.texi
     
    206206halfway done.  The moves are stored, but not the attack and defend 
    207207codes (LOSE, KO_A, KO_B and WIN). 
    208208@item Make the cache not waste storage on 64 bit systems. 
    209 @item  Implement detection of superko violation in the board code. We 
    210 probably only want this optionally in @code{play_move()} and in a variant 
    211 of @code{is_legal()}. 
    212209@item The dragon data is split into two arrays, @code{dragon[]} 
    213210and @code{dragon2[]}. The dragon2 array only have one entry per dragon, in 
    214211contrast to the dragon array where all the data is stored once for every 
  • doc/using.texi

    RCS file: /cvsroot/gnugo/gnugo/doc/using.texi,v
    retrieving revision 1.30
    diff -u -r1.30 using.texi
     
    496496Use Japanese Rules. This is the default unless you specify 
    497497@option{--enable-chinese-rules} as a configure option. 
    498498@end quotation 
     499@item @option{--forbid-suicide}  
     500@quotation 
     501Do not allow suicide moves (playing a stone so that it ends up without 
     502liberties and is therefore immediately removed). This is the default. 
     503@end quotation 
     504@item @option{--allow-suicide}  
     505@quotation 
     506Allow suicide moves, except single-stone suicide. The latter would not 
     507change the board at all and pass should be used instead. 
     508@end quotation 
     509@item @option{--allow-all-suicide}  
     510@quotation 
     511Allow suicide moves, including single-stone suicide. This is only 
     512interesting in exceptional cases. Normally the 
     513@option{--allow-suicide} option should be used instead. 
     514@end quotation 
     515@item @option{--simple-ko}  
     516@quotation 
     517Do not allow an immediate recapture of a ko so that the previous 
     518position is recreated. Repetition of earlier positions than that are 
     519allowed. This is default. 
     520@end quotation 
     521@item @option{--no-ko}  
     522@quotation 
     523Allow all kinds of board repetition. 
     524@end quotation 
     525@item @option{--positional-superko}  
     526@quotation 
     527Forbid repetition of any earlier board position. This only applies to 
     528moves on the board; passing is always allowed. 
     529@end quotation 
     530@item @option{--situational-superko}  
     531@quotation 
     532Forbid repetition of any earlier board position with the same player 
     533to move. This only applies to moves on the board; passing is always 
     534allowed. 
     535@end quotation 
    499536@item @option{--copyright}: Display the copyright notice 
    500537@item @option{--version} or @option{-v}: Print the version number 
    501538@item @option{--printsgf @var{filename}}:  
  • engine/board.c

    RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
    retrieving revision 1.118
    diff -u -r1.118 board.c
     
    300300 
    301301 
    302302/* Forward declarations. */ 
     303static void really_do_trymove(int pos, int color); 
    303304static int do_trymove(int pos, int color, int ignore_ko); 
    304305static void undo_trymove(void); 
    305306 
     
    307308static int slow_approxlib(int pos, int color, int maxlib, int *libs); 
    308309static int do_accuratelib(int pos, int color, int maxlib, int *libs); 
    309310 
     311static int is_superko_violation(int pos, int color, enum ko_rules type); 
     312 
    310313static void new_position(void); 
    311314static int propagate_string(int stone, int str); 
    312315static void find_liberties_and_neighbors(int s); 
     
    360363  for (k = 0; k < move_history_pointer; k++) { 
    361364    state->move_history_color[k] = move_history_color[k]; 
    362365    state->move_history_pos[k] = move_history_pos[k]; 
     366    state->move_history_hash[k] = move_history_hash[k]; 
    363367  } 
    364368 
    365369  state->komi = komi; 
     
    396400  for (k = 0; k < move_history_pointer; k++) { 
    397401    move_history_color[k] = state->move_history_color[k]; 
    398402    move_history_pos[k] = state->move_history_pos[k]; 
     403    move_history_hash[k] = state->move_history_hash[k]; 
    399404  } 
    400405 
    401406  komi = state->komi; 
     
    598603  return 1; 
    599604} 
    600605 
     606/* Really, really make a temporary move. It is assumed that all 
     607 * necessary checks have already been made and likewise that various 
     608 * administrative bookkeeping outside of the actual board logic has 
     609 * either been done or is not needed. 
     610 */ 
     611static void 
     612really_do_trymove(int pos, int color) 
     613{ 
     614  BEGIN_CHANGE_RECORD(); 
     615  PUSH_VALUE(board_ko_pos); 
     616 
     617  /* 
     618   * FIXME: Do we really have to store board_hash in a stack? 
     619   * 
     620   * Answer: No, we don't.  But for every stone that we add 
     621   *         or remove, we must call hashdata_invert_stone(). This is 
     622   *         not difficult per se, but the whole board.c  
     623   *         will have to be checked, and there is lots of room 
     624   *         for mistakes. 
     625   * 
     626   *         At the same time, profiling shows that storing the 
     627   *         hashdata in a stack doesn't take a lot of time, so 
     628   *         this is not an urgent FIXME. 
     629   */ 
     630  memcpy(&board_hash_stack[stackp], &board_hash, sizeof(board_hash)); 
     631 
     632  if (board_ko_pos != NO_MOVE) 
     633    hashdata_invert_ko(&board_hash, board_ko_pos); 
     634 
     635  board_ko_pos = NO_MOVE; 
     636   
     637  stackp++; 
     638 
     639  if (pos != PASS_MOVE) { 
     640    PUSH_VALUE(black_captured); 
     641    PUSH_VALUE(white_captured); 
     642    do_play_move(pos, color); 
     643  } 
     644} 
    601645 
    602646/* 
    603647 * Do the main work of trymove() and tryko(), i.e. the common parts. 
     
    663707  stack[stackp] = pos; 
    664708  move_color[stackp] = color; 
    665709 
    666   /* 
    667    * FIXME: Do we really have to store board_hash in a stack? 
    668    * 
    669    * Answer: No, we don't.  But for every stone that we add 
    670    *         or remove, we must call hashdata_invert_stone(). This is 
    671    *         not difficult per se, but the whole board.c  
    672    *         will have to be checked, and there is lots of room 
    673    *         for mistakes. 
    674    * 
    675    *         At the same time, profiling shows that storing the 
    676    *         hashdata in a stack doesn't take a lot of time, so 
    677    *         this is not an urgent FIXME. 
    678    */ 
    679   BEGIN_CHANGE_RECORD(); 
    680   PUSH_VALUE(board_ko_pos); 
    681   memcpy(&board_hash_stack[stackp], &board_hash, sizeof(board_hash)); 
    682  
    683   if (board_ko_pos != NO_MOVE) 
    684     hashdata_invert_ko(&board_hash, board_ko_pos); 
    685  
    686   board_ko_pos = NO_MOVE; 
    687    
    688   stackp++; 
    689  
    690   if (pos != PASS_MOVE) { 
    691     PUSH_VALUE(black_captured); 
    692     PUSH_VALUE(white_captured); 
    693     do_play_move(pos, color); 
    694   } 
     710  really_do_trymove(pos, color); 
    695711 
    696712  return 1; 
    697713} 
     
    704720void 
    705721popgo() 
    706722{ 
    707   stackp--; 
    708    
    709723  undo_trymove(); 
    710724   
    711   memcpy(&board_hash, &(board_hash_stack[stackp]), sizeof(board_hash)); 
    712  
    713725  if (sgf_dumptree) { 
    714726    char buf[100]; 
    715727    int is_tryko = 0; 
     
    733745} 
    734746 
    735747 
    736 #if 0 
    737  
    738 /* Silent version of popgo(), suitable for use if you have called 
    739  * do_trymove() without passing through trymove() or tryko(). 
    740  */ 
    741  
    742 static void 
    743 silent_popgo(void) 
    744 { 
    745   stackp--; 
    746   undo_trymove(); 
    747   memcpy(&board_hash, &(board_hash_stack[stackp]), sizeof(board_hash)); 
    748 } 
    749  
    750 #endif 
    751  
    752748/* Restore board state to the position before the last move. This is 
    753749 * accomplished by popping everything that was stored on the stacks 
    754  * since the last BEGIN_CHANGE_RECORD(). 
     750 * since the last BEGIN_CHANGE_RECORD(). Also stackp is decreased and 
     751 * board hash is restored from stack. 
     752 * 
     753 * This undoes the effects of do_trymove() or really_do_trymove() and 
     754 * is appropriate to call instead of popgo() if you have not passed 
     755 * through trymove() or tryko(). 
    755756 */ 
    756757 
    757758static void 
     
    766767 
    767768  POP_MOVE(); 
    768769  POP_VERTICES(); 
     770   
     771  stackp--; 
     772  memcpy(&board_hash, &(board_hash_stack[stackp]), sizeof(board_hash)); 
    769773} 
    770774 
    771775 
     
    960964    for (k = number_collapsed_moves; k < move_history_pointer; k++) { 
    961965      move_history_color[k - number_collapsed_moves] = move_history_color[k]; 
    962966      move_history_pos[k - number_collapsed_moves] = move_history_pos[k]; 
     967      move_history_hash[k - number_collapsed_moves] = move_history_hash[k]; 
    963968    } 
    964969    move_history_pointer -= number_collapsed_moves; 
    965970 
     
    972977 
    973978  move_history_color[move_history_pointer] = color; 
    974979  move_history_pos[move_history_pointer] = pos; 
     980  move_history_hash[move_history_pointer] = board_hash; 
     981  if (board_ko_pos != NO_MOVE) 
     982    hashdata_invert_ko(&move_history_hash[move_history_pointer], board_ko_pos); 
    975983  move_history_pointer++; 
    976984   
    977985  play_move_no_history(pos, color, 1); 
     
    10571065 
    10581066 
    10591067/* 
    1060  * is_legal(pos, color) determines whether the move (color) at 
    1061  * pos is legal. 
     1068 * is_legal(pos, color) determines whether the move (color) at pos is 
     1069 * legal. This is for internal use in the engine and always assumes 
     1070 * that suicide is allowed and only simple ko restrictions, no 
     1071 * superko, regardless of the rules actually used in the game. 
     1072 * 
     1073 * Use is_allowed_move() if you want to take alternative suicide and 
     1074 * ko rules into account. 
    10621075 */ 
    10631076 
    10641077int  
     
    10761089    return 0; 
    10771090 
    10781091  /* 3. The location must not be the ko point. */ 
    1079   if (pos == board_ko_pos) 
     1092  if (pos == board_ko_pos) { 
     1093    /*    The ko position is guaranteed to have all neighbors of the 
     1094     *    same color, or off board. If that color is the same as the 
     1095     *    move the ko is being filled, which is always allowed. This 
     1096     *    could be tested with has_neighbor() but here a faster test 
     1097     *    suffices. 
     1098     */ 
    10801099    if (board[WEST(pos)] == OTHER_COLOR(color) 
    10811100        || board[EAST(pos)] == OTHER_COLOR(color)) { 
    10821101      return 0; 
    10831102    } 
     1103  } 
    10841104 
    10851105  /* Check for stack overflow. */ 
    10861106  if (stackp >= MAXSTACK-2) { 
     
    10941114  } 
    10951115 
    10961116  /* Check for suicide. */ 
    1097   if (!allow_suicide && is_suicide(pos, color)) 
     1117  if (is_suicide(pos, color)) 
    10981118    return 0; 
    10991119   
    11001120  return 1; 
     
    11561176              || (board[EAST(pos)] == OTHER_COLOR(color)))); 
    11571177} 
    11581178 
     1179/* 
     1180 * is_allowed_move(int pos, int color) determines whether a move is 
     1181 * legal with respect to the suicide and ko rules in play. 
     1182 * 
     1183 * This function is only valid when stackp == 0 since there is no 
     1184 * tracking of superko for trymoves. 
     1185 */ 
     1186int 
     1187is_allowed_move(int pos, int color) 
     1188{ 
     1189  gg_assert(stackp == 0); 
     1190 
     1191  /* 1. A pass move is always legal, no matter what. */ 
     1192  if (pos == PASS_MOVE) 
     1193    return 1; 
     1194 
     1195  /* 2. The move must be inside the board. */ 
     1196  ASSERT_ON_BOARD1(pos); 
     1197 
     1198  /* 3. The location must be empty. */ 
     1199  if (board[pos] != EMPTY)  
     1200    return 0; 
     1201 
     1202  /* 4. Simple ko repetition is only allowed if no ko rule is in use. 
     1203   *    For superko rules this check is redundant. 
     1204   * 
     1205   *    The ko position is guaranteed to have all neighbors of the 
     1206   *    same color, or off board. If that color is the same as the 
     1207   *    move the ko is being filled, which is always allowed. This 
     1208   *    could be tested with has_neighbor() but here a faster test 
     1209   *    suffices. 
     1210   */ 
     1211  if (ko_rule != NONE 
     1212      && pos == board_ko_pos 
     1213      && (board[WEST(pos)] == OTHER_COLOR(color) 
     1214          || board[EAST(pos)] == OTHER_COLOR(color))) 
     1215    return 0; 
     1216 
     1217  /* 5. Check for suicide. Suicide rule options: 
     1218   *    FORBIDDEN   - No suicides allowed. 
     1219   *    ALLOWED     - Suicide of more than one stone allowed. 
     1220   *    ALL_ALLOWED - All suicides allowed. 
     1221   */ 
     1222  if (is_suicide(pos, color)) 
     1223    if (suicide_rule == FORBIDDEN 
     1224        || (suicide_rule == ALLOWED 
     1225            && !has_neighbor(pos, color))) 
     1226      return 0; 
     1227 
     1228  /* 6. Check for whole board repetitions. The superko options are 
     1229   *    SIMPLE, NONE - No superko restrictions. 
     1230   *    PSK          - Repetition of a previous position forbidden. 
     1231   *    SSK          - Repetition of a previous position with the same 
     1232   *                   player to move forbidden. 
     1233   */ 
     1234  if (is_superko_violation(pos, color, ko_rule)) 
     1235    return 0; 
     1236   
     1237  return 1; 
     1238} 
     1239 
    11591240/* Necessary work to set the new komaster state. */ 
    11601241static void 
    11611242set_new_komaster(int new_komaster) 
     
    29383019} 
    29393020 
    29403021 
     3022/* Return true if a move by color at pos is a superko violation 
     3023 * according to the specified type of ko rules. This function does not 
     3024 * detect simple ko unless it's also a superko violation. 
     3025 * 
     3026 * The superko detection is done by comparing board hashes from 
     3027 * previous positions. For this to work correctly it's necessary to 
     3028 * remove the contribution to the hash from the simple ko position. 
     3029 * The move_history_hash array contains board hashes for previous 
     3030 * positions, also without simple ko position contributions. 
     3031 */ 
     3032static int 
     3033is_superko_violation(int pos, int color, enum ko_rules type) 
     3034{ 
     3035  Hash_data this_board_hash = board_hash; 
     3036  Hash_data new_board_hash; 
     3037  int k; 
     3038 
     3039  /* No superko violations if the ko rule is not a superko rule. */ 
     3040  if (type == NONE || type == SIMPLE) 
     3041    return 0; 
     3042 
     3043  if (board_ko_pos != NO_MOVE) 
     3044    hashdata_invert_ko(&this_board_hash, board_ko_pos); 
     3045 
     3046  really_do_trymove(pos, color); 
     3047  new_board_hash = board_hash; 
     3048  if (board_ko_pos != NO_MOVE) 
     3049    hashdata_invert_ko(&new_board_hash, board_ko_pos); 
     3050  undo_trymove(); 
     3051 
     3052  /* The current position is only a problem with positional superko 
     3053   * and a single stone suicide. 
     3054   */ 
     3055  if (type == PSK && hashdata_is_equal(this_board_hash, new_board_hash)) 
     3056    return 1; 
     3057 
     3058  for (k = move_history_pointer - 1; k >= 0; k--) 
     3059    if (hashdata_is_equal(move_history_hash[k], new_board_hash) 
     3060        && (type == PSK 
     3061            || move_history_color[k] == OTHER_COLOR(color))) 
     3062      return 1; 
     3063 
     3064  return 0; 
     3065} 
     3066 
    29413067/* Returns 1 if at least one string is captured when color plays at pos. 
    29423068 */ 
    29433069int 
  • engine/board.h

    RCS file: /cvsroot/gnugo/gnugo/engine/board.h,v
    retrieving revision 1.33
    diff -u -r1.33 board.h
     
    2323#ifndef _BOARD_H_ 
    2424#define _BOARD_H_ 
    2525 
     26#include <stdarg.h> 
     27#include "config.h" 
    2628#include "sgftree.h" 
    2729#include "winsocket.h" 
    28 #include "config.h" 
    29 #include <stdarg.h> 
     30 
     31/* This type is used to store each intersection on the board. 
     32 * 
     33 * On a 486, char is best, since the time taken to push and pop 
     34 * becomes significant otherwise. On other platforms, an int may 
     35 * be better, e.g. if memcpy() is particularly fast, or if 
     36 * character access is very slow. 
     37 */ 
     38 
     39typedef unsigned char Intersection; 
     40 
     41/* FIXME: This is very ugly but we can't include hash.h until we have 
     42 * defined Intersection. And we do need to include it before using 
     43 * Hash_data. 
     44 */ 
     45#include "hash.h" 
    3046 
    3147/* local versions of absolute value, min and max */ 
    3248 
     
    117133#define OTHER_COLOR(color)      (WHITE+BLACK-(color)) 
    118134#define IS_STONE(arg)           ((arg) == WHITE || (arg) == BLACK) 
    119135 
    120 /* This type is used to store each intersection on the board. 
    121  * 
    122  * On a 486, char is best, since the time taken to push and pop 
    123  * becomes significant otherwise. On other platforms, an int may 
    124  * be better, e.g. if memcpy() is particularly fast, or if 
    125  * character access is very slow. 
    126  */ 
    127  
    128 typedef unsigned char Intersection; 
    129  
    130  
    131  
    132136/* Note that POS(-1, -1) == 0 
    133137 * DELTA() is defined so that POS(i+di, j+dj) = POS(i, j) + DELTA(di, dj). 
    134138 */ 
     
    190194extern int          initial_black_captured; 
    191195extern int          move_history_color[MAX_MOVE_HISTORY]; 
    192196extern int          move_history_pos[MAX_MOVE_HISTORY]; 
     197extern Hash_data    move_history_hash[MAX_MOVE_HISTORY]; 
    193198extern int          move_history_pointer; 
    194199 
    195200extern float        komi; 
     
    198203                     
    199204extern signed char  shadow[BOARDMAX];      /* reading tree shadow */ 
    200205 
    201 extern int chinese_rules; 
    202 extern int allow_suicide; 
     206enum suicide_rules { 
     207  FORBIDDEN, 
     208  ALLOWED, 
     209  ALL_ALLOWED 
     210}; 
     211extern enum suicide_rules suicide_rule; 
     212 
     213enum ko_rules { 
     214  SIMPLE, 
     215  NONE, 
     216  PSK, 
     217  SSK 
     218}; 
     219extern enum ko_rules ko_rule; 
     220 
    203221 
    204222extern int stackp;                /* stack pointer */ 
    205223extern int count_variations;      /* count (decidestring) */ 
     
    221239  int initial_black_captured; 
    222240  int move_history_color[MAX_MOVE_HISTORY]; 
    223241  int move_history_pos[MAX_MOVE_HISTORY]; 
     242  Hash_data move_history_hash[MAX_MOVE_HISTORY]; 
    224243  int move_history_pointer; 
    225244 
    226245  float komi; 
     
    280299int is_legal(int pos, int color); 
    281300int is_suicide(int pos, int color); 
    282301int is_illegal_ko_capture(int pos, int color); 
     302int is_allowed_move(int pos, int color); 
    283303int is_ko(int pos, int color, int *ko_pos); 
    284304int is_ko_point(int pos); 
    285305int does_capture_something(int pos, int color); 
  • engine/boardlib.c

    RCS file: /cvsroot/gnugo/gnugo/engine/boardlib.c,v
    retrieving revision 1.11
    diff -u -r1.11 boardlib.c
     
    3939int          initial_black_captured; 
    4040int          move_history_color[MAX_MOVE_HISTORY]; 
    4141int          move_history_pos[MAX_MOVE_HISTORY]; 
     42Hash_data    move_history_hash[MAX_MOVE_HISTORY]; 
    4243int          move_history_pointer; 
    4344 
    4445float komi = 0.0; 
    4546int handicap = 0; 
    4647int movenum; 
    47 int allow_suicide = 0;  /* allow opponent to make suicide moves */ 
     48enum suicide_rules suicide_rule = FORBIDDEN; 
     49enum ko_rules ko_rule = SIMPLE; 
    4850 
    4951 
    5052signed char shadow[BOARDMAX]; 
  • engine/genmove.c

    RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v
    retrieving revision 1.114
    diff -u -r1.114 genmove.c
     
    508508    } 
    509509  } 
    510510 
     511  /* If we somehow have managed to generate an illegal move, pass instead. */ 
     512  if (!is_allowed_move(move, color)) { 
     513    TRACE("ILLEGAL MOVE GENERATED. Passing instead.\n"); 
     514    move = PASS_MOVE; 
     515    *value = -1.0; 
     516  } 
     517   
    511518  /* If no move is found then pass. */ 
    512519  if (move == PASS_MOVE) { 
    513520    TRACE("I pass.\n"); 
  • engine/value_moves.c

    RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
    retrieving revision 1.168
    diff -u -r1.168 value_moves.c
     
    34213421 
    34223422  ko_move_target = get_biggest_owl_target(ko_move); 
    34233423   
    3424   /* Find the ko stone. */ 
    3425   for (k = 0; k <= 3; k++) { 
    3426     ko_stone = ko_move + delta[k]; 
    3427     if (ON_BOARD(ko_stone) && countlib(ko_stone) == 1) 
    3428       break; 
     3424  /* If the move is a simple ko recapture, find the ko stone. (If 
     3425   * it's not a simple ko recapture, then the move must be a superko 
     3426   * violation.) 
     3427   */ 
     3428  if (is_illegal_ko_capture(ko_move, color)) { 
     3429    for (k = 0; k <= 3; k++) { 
     3430      ko_stone = ko_move + delta[k]; 
     3431      if (ON_BOARD(ko_stone) && countlib(ko_stone) == 1) 
     3432        break; 
     3433    } 
     3434    ASSERT_ON_BOARD1(ko_stone); 
    34293435  } 
    3430   ASSERT_ON_BOARD1(ko_stone); 
    34313436   
    34323437  TRACE("Reevaluating ko threats.\n"); 
    34333438  for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     
    34913496    /* If there is no threat recorded, the followup value is probably 
    34923497     * contributed by a pattern. We can do nothing but accept this value. 
    34933498     * (although this does cause problems). 
     3499     * 
     3500     * FIXME: In the case of superko violation we have no ko_stone. 
     3501     * Presumably some of the tests below should be applicable anyway. 
     3502     * Currently we just say that any threat is ok. 
    34943503     */ 
    3495     if (type == -1) 
     3504    if (type == -1 || ko_stone == NO_MOVE) 
    34963505      threat_does_work = 1; 
    34973506    else { 
    34983507      if (trymove(pos, color, "reevaluate_ko_threats", ko_move)) { 
     
    36863695    /* If the best move is an illegal ko capture, reevaluate ko 
    36873696     * threats and search again. 
    36883697     */ 
    3689     if (best_value > 0.0 && is_illegal_ko_capture(best_move, color)) { 
     3698    if (best_value > 0.0 
     3699        && (is_illegal_ko_capture(best_move, color) 
     3700            || !is_allowed_move(best_move, color))) { 
    36903701      TRACE("Move at %1m would be an illegal ko capture.\n", best_move); 
    36913702      reevaluate_ko_threats(best_move, color, best_value); 
    36923703      redistribute_points(); 
  • interface/main.c

    RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v
    retrieving revision 1.133
    diff -u -r1.133 main.c
     
    143143      OPT_OWL_THREATS, 
    144144      OPT_NO_OWL_THREATS, 
    145145      OPT_JAPANESE_RULES, 
     146      OPT_FORBID_SUICIDE, 
    146147      OPT_ALLOW_SUICIDE, 
     148      OPT_ALLOW_ALL_SUICIDE, 
     149      OPT_SIMPLE_KO, 
     150      OPT_NO_KO, 
     151      OPT_POSITIONAL_SUPERKO, 
     152      OPT_SITUATIONAL_SUPERKO, 
    147153      OPT_CAPTURE_ALL_DEAD, 
    148154      OPT_PLAY_OUT_AFTERMATH, 
    149155      OPT_MIRROR, 
     
    249255  {"standard-connections",  no_argument, 0, OPT_STANDARD_CONNECTIONS}, 
    250256  {"standard-semeai", no_argument,      0, OPT_STANDARD_SEMEAI}, 
    251257  {"alternate-connections",  no_argument, 0, OPT_ALTERNATE_CONNECTIONS}, 
    252   {"with-break-in",     no_argument, 0, OPT_WITH_BREAK_IN}, 
    253   {"without-break-in",  no_argument, 0, OPT_WITHOUT_BREAK_IN}, 
    254   {"cosmic-gnugo",   no_argument, 0, OPT_COSMIC_GNUGO}, 
    255   {"no-cosmic-gnugo",   no_argument, 0, OPT_NO_COSMIC_GNUGO}, 
    256   {"large-scale",    no_argument, 0, OPT_LARGE_SCALE}, 
    257   {"no-large-scale",    no_argument, 0, OPT_NO_LARGE_SCALE}, 
    258   {"options",        no_argument, 0, OPT_OPTIONS}, 
    259   {"allow-suicide",  no_argument,       0, OPT_ALLOW_SUICIDE}, 
    260   {"capture-all-dead",   no_argument,   0, OPT_CAPTURE_ALL_DEAD}, 
    261   {"play-out-aftermath", no_argument,   0, OPT_PLAY_OUT_AFTERMATH}, 
     258  {"with-break-in",        no_argument, 0, OPT_WITH_BREAK_IN}, 
     259  {"without-break-in",     no_argument, 0, OPT_WITHOUT_BREAK_IN}, 
     260  {"cosmic-gnugo",         no_argument, 0, OPT_COSMIC_GNUGO}, 
     261  {"no-cosmic-gnugo",      no_argument, 0, OPT_NO_COSMIC_GNUGO}, 
     262  {"large-scale",          no_argument, 0, OPT_LARGE_SCALE}, 
     263  {"no-large-scale",       no_argument, 0, OPT_NO_LARGE_SCALE}, 
     264  {"options",              no_argument, 0, OPT_OPTIONS}, 
     265  {"forbid-suicide",       no_argument, 0, OPT_FORBID_SUICIDE}, 
     266  {"allow-suicide",        no_argument, 0, OPT_ALLOW_SUICIDE}, 
     267  {"allow-all-suicide",    no_argument, 0, OPT_ALLOW_ALL_SUICIDE}, 
     268  {"simple-ko",            no_argument, 0, OPT_SIMPLE_KO}, 
     269  {"no-ko",                no_argument, 0, OPT_NO_KO}, 
     270  {"positional-superko",   no_argument, 0, OPT_POSITIONAL_SUPERKO}, 
     271  {"situational-superko",  no_argument, 0, OPT_SITUATIONAL_SUPERKO}, 
     272  {"capture-all-dead",     no_argument, 0, OPT_CAPTURE_ALL_DEAD}, 
     273  {"play-out-aftermath",   no_argument, 0, OPT_PLAY_OUT_AFTERMATH}, 
    262274  {"cache-size",     required_argument, 0, 'M'}, 
    263275  {"worms",          no_argument,       0, 'w'}, 
    264276  {"moyo",           required_argument, 0, 'm'}, 
     
    583595        large_scale = 0; 
    584596        break; 
    585597 
     598      case OPT_FORBID_SUICIDE: 
     599        suicide_rule = FORBIDDEN; 
     600        break; 
     601 
    586602      case OPT_ALLOW_SUICIDE: 
    587         allow_suicide = 1; 
     603        suicide_rule = ALLOWED; 
     604        break; 
     605 
     606      case OPT_ALLOW_ALL_SUICIDE: 
     607        suicide_rule = ALL_ALLOWED; 
     608        break; 
     609 
     610      case OPT_SIMPLE_KO: 
     611        ko_rule = SIMPLE; 
     612        break; 
     613 
     614      case OPT_NO_KO: 
     615        ko_rule = NONE; 
     616        break; 
     617 
     618      case OPT_POSITIONAL_SUPERKO: 
     619        ko_rule = PSK; 
     620        break; 
     621 
     622      case OPT_SITUATIONAL_SUPERKO: 
     623        ko_rule = SSK; 
    588624        break; 
    589625 
    590626      case OPT_CAPTURE_ALL_DEAD: 
     
    14411477\n\ 
    14421478   --japanese-rules     (default)\n\ 
    14431479   --chinese-rules\n\ 
    1444    --allow-suicide\n\ 
     1480   --forbid-suicide      Forbid suicide. (default)\n\ 
     1481   --allow-suicide       Allow suicide except single-stone suicide.\n\ 
     1482   --allow-all-suicide   Allow all suicide moves.\n\ 
     1483   --simple-ko           Forbid simple ko recapture. (default)\n\ 
     1484   --no-ko               Allow any ko recapture.\n\ 
     1485   --positional-superko  Positional superko restrictions.\n\ 
     1486   --situational-superko Situational superko restrictions.\n\ 
    14451487\n\ 
    14461488   --play-out-aftermath\n\ 
    14471489   --capture-all-dead\n\ 
  • interface/play_ascii.c

    RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v
    retrieving revision 1.70
    diff -u -r1.70 play_ascii.c
     
    520520    return 0; 
    521521  } 
    522522   
    523   if (!is_legal(move, gameinfo->to_move)) { 
     523  if (!is_allowed_move(move, gameinfo->to_move)) { 
    524524    printf("\nIllegal move: %s", command); 
    525525    return 0; 
    526526  } 
  • interface/play_gtp.c

    RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
    retrieving revision 1.181
    diff -u -r1.181 play_gtp.c
    </
     
    605605  else if (!gtp_decode_coord(s, &i, &j)) 
    606606    return gtp_failure("invalid coordinate"); 
    607607 
    608   if (!is_legal(POS(i, j), BLACK)) 
     608  if (!is_allowed_move(POS(i, j), BLACK)) 
    609609    return gtp_failure("illegal move"); 
    610610 
    611611  gnugo_play_move(POS(i, j), BLACK); 
     
    636636  else if (!gtp_decode_coord(s, &i, &j)) 
    637637    return gtp_failure("invalid coordinate"); 
    638638