diff -N -r -u -X .ignore gnugo-copy/engine/board.c gnugo/engine/board.c
|
old
|
new
|
|
| 3310 | 3310 | } |
| 3311 | 3311 | |
| 3312 | 3312 | /* |
| | 3313 | * If (pos) has exactly one neighbor of color (color) |
| | 3314 | * returns position of this neighbor. Otherwise returns -1. |
| | 3315 | */ |
| | 3316 | |
| | 3317 | int |
| | 3318 | find_neighbor(int pos, int color) |
| | 3319 | { |
| | 3320 | int npos; |
| | 3321 | |
| | 3322 | ASSERT_ON_BOARD1(pos); |
| | 3323 | ASSERT1(IS_STONE(color), pos); |
| | 3324 | |
| | 3325 | if (board[SOUTH(pos)] == color) |
| | 3326 | npos = SOUTH(pos); |
| | 3327 | else |
| | 3328 | npos = 0; |
| | 3329 | if (board[WEST(pos)] == color) { |
| | 3330 | if (npos) |
| | 3331 | npos = -1; |
| | 3332 | else |
| | 3333 | npos = WEST(pos); |
| | 3334 | } |
| | 3335 | if (board[NORTH(pos)] == color) { |
| | 3336 | if (npos) |
| | 3337 | npos = -1; |
| | 3338 | else |
| | 3339 | npos = NORTH(pos); |
| | 3340 | } |
| | 3341 | if (board[EAST(pos)] == color) { |
| | 3342 | if (npos) |
| | 3343 | npos = -1; |
| | 3344 | else |
| | 3345 | npos = EAST(pos); |
| | 3346 | } |
| | 3347 | return npos ? npos : -1; |
| | 3348 | } |
| | 3349 | |
| | 3350 | /* |
| 3313 | 3351 | * Returns true if str1_pos and str2_pos belong to the same string. |
| 3314 | 3352 | */ |
| 3315 | 3353 | |
diff -N -r -u -X .ignore gnugo-copy/engine/board.h gnugo/engine/board.h
|
old
|
new
|
|
| 330 | 330 | int second_order_liberty_of_string(int pos, int str_pos); |
| 331 | 331 | int neighbor_of_string(int pos, int str_pos); |
| 332 | 332 | int has_neighbor(int pos, int color); |
| | 333 | int find_neighbor(int pos, int color); |
| 333 | 334 | int same_string(int str1_pos, int str2_pos); |
| 334 | 335 | int adjacent_strings(int str1_pos, int str2_pos); |
| 335 | 336 | void mark_string(int str, signed char mx[BOARDMAX], signed char mark); |
diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
|
old
|
new
|
|
| 175 | 175 | int ko_move; \ |
| 176 | 176 | int apos = moves.pos[k]; \ |
| 177 | 177 | \ |
| 178 | | if (komaster_trymove(apos, other, moves.message[k], str,&ko_move, \ |
| 179 | | stackp <= ko_depth && savecode == 0)) { \ |
| | 178 | if ((board_ko_pos || !send_two_return_one(apos, other)) \ |
| | 179 | && komaster_trymove(apos, other,moves.message[k],str,&ko_move,\ |
| | 180 | stackp <= ko_depth && savecode == 0)) { \ |
| 180 | 181 | int dcode = do_find_defense(str, (defense_hint)); \ |
| 181 | 182 | \ |
| 182 | 183 | if (REVERSE_RESULT(dcode) > savecode \ |
| … |
… |
|
| 1452 | 1453 | |
| 1453 | 1454 | /* If the string is a single stone and a capture would give a ko, |
| 1454 | 1455 | * try to defend it with ko by backfilling. |
| 1455 | | * |
| 1456 | | * FIXME: What is an example of this? Is it correct that the |
| 1457 | | * return value is WIN and not KO_A or KO_B? |
| | 1456 | * If we don't find any defending move return LOSE and not KO_B, |
| | 1457 | * because we'll lose this ko sooner or later. |
| 1458 | 1458 | */ |
| 1459 | 1459 | if (stackp <= backfill_depth |
| 1460 | 1460 | && countstones(str) == 1 |
diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
|
old
|
new
|
|
| 1434 | 1434 | int other = OTHER_COLOR(color); |
| 1435 | 1435 | int lib1; |
| 1436 | 1436 | int lib2; |
| | 1437 | int neighbor; |
| | 1438 | |
| | 1439 | /* We must check this, because in such position: |
| | 1440 | * |
| | 1441 | * ----- |
| | 1442 | * O.*OX |
| | 1443 | * OOXXX |
| | 1444 | * |
| | 1445 | * move * prevents making an eye by X player. |
| | 1446 | */ |
| | 1447 | neighbor = find_neighbor(move, color); |
| | 1448 | if (neighbor == -1 || countlib(neighbor) != 2) |
| | 1449 | return 0; |
| 1437 | 1450 | |
| 1438 | 1451 | /* Try to play the move. */ |
| 1439 | 1452 | if (!trymove(move, color, "send_two_return_one-A", NO_MOVE)) |