RCS file: /sources/gnugo/gnugo/engine/unconditional.c,v
retrieving revision 1.5
diff -u -r1.5 unconditional.c
|
|
|
|
| 57 | 57 | string_found = 0; |
| 58 | 58 | |
| 59 | 59 | /* Visit all friendly strings on the board. */ |
| 60 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 60 | scan_board(pos, |
| 61 | 61 | if (board[pos] != color || find_origin(pos) != pos) |
| 62 | 62 | continue; |
| 63 | 63 | |
| … |
… |
|
| 101 | 101 | popgo(); |
| 102 | 102 | moves_played--; |
| 103 | 103 | } |
| 104 | | } |
| | 104 | ) |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (none_invincible) |
| … |
… |
|
| 331 | 331 | * kind of seki described in the comments. |
| 332 | 332 | */ |
| 333 | 333 | memset(potential_sekis, 0, sizeof(potential_sekis)); |
| 334 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 334 | scan_board(pos, |
| 335 | 335 | int isolated = 1; |
| 336 | 336 | int stones[2]; |
| 337 | 337 | int pos2; |
| … |
… |
|
| 356 | 356 | potential_sekis[stones[0]] = 1; |
| 357 | 357 | potential_sekis[stones[1]] = 1; |
| 358 | 358 | } |
| 359 | | } |
| | 359 | ) |
| 360 | 360 | |
| 361 | 361 | moves_played = capture_non_invincible_strings(color, potential_sekis, |
| 362 | 362 | &none_invincible); |
| … |
… |
|
| 380 | 380 | * 1. Play opponent stones on all liberties of the unconditionally |
| 381 | 381 | * alive strings except where illegal. |
| 382 | 382 | */ |
| 383 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 383 | scan_board(pos, |
| 384 | 384 | if (board[pos] != color || potential_sekis[pos] || find_origin(pos) != pos) |
| 385 | 385 | continue; |
| 386 | 386 | |
| … |
… |
|
| 390 | 390 | if (trymove(libs[k], other, "unconditional_life", pos)) |
| 391 | 391 | moves_played++; |
| 392 | 392 | } |
| 393 | | } |
| | 393 | ) |
| 394 | 394 | |
| 395 | 395 | /* 2. Recursively extend opponent strings in atari, except where this |
| 396 | 396 | * would be suicide. |
| … |
… |
|
| 400 | 400 | /* Nothing found so far in this turn of the loop. */ |
| 401 | 401 | found_one = 0; |
| 402 | 402 | |
| 403 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 403 | scan_board(pos, |
| 404 | 404 | if (board[pos] != other || countlib(pos) > 1) |
| 405 | 405 | continue; |
| 406 | 406 | |
| … |
… |
|
| 410 | 410 | moves_played++; |
| 411 | 411 | found_one = 1; |
| 412 | 412 | } |
| 413 | | } |
| | 413 | ) |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /* Now see whether there are any significant sekis on the board. */ |
| 417 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 417 | scan_board(pos, |
| 418 | 418 | if (!potential_sekis[pos] |
| 419 | 419 | || board[pos] == EMPTY |
| 420 | 420 | || find_origin(pos) != pos) |
| … |
… |
|
| 461 | 461 | if (countstones(pos) > 2) |
| 462 | 462 | break; |
| 463 | 463 | } |
| 464 | | } |
| | 464 | ) |
| 465 | 465 | |
| 466 | 466 | /* Capture the strings involved in potential sekis. */ |
| 467 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 467 | scan_board(pos, |
| 468 | 468 | if (!potential_sekis[pos] || board[pos] == EMPTY) |
| 469 | 469 | continue; |
| 470 | 470 | /* Play as many liberties as we can. */ |
| … |
… |
|
| 473 | 473 | if (trymove(libs[k], other, "unconditional_life", pos)) |
| 474 | 474 | moves_played++; |
| 475 | 475 | } |
| 476 | | } |
| | 476 | ) |
| 477 | 477 | |
| 478 | 478 | |
| 479 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 479 | scan_board(pos, |
| 480 | 480 | int apos; |
| 481 | 481 | int bpos; |
| 482 | | int aopen, bopen; |
| 483 | | int alib, blib; |
| | 482 | int aopen; |
| | 483 | int bopen; |
| | 484 | int alib; |
| | 485 | int blib; |
| 484 | 486 | if (board[pos] != other || countlib(pos) != 2) |
| 485 | 487 | continue; |
| 486 | 488 | findlib(pos, 2, libs); |
| … |
… |
|
| 515 | 517 | trymove(bpos, other, "unconditional_life", pos); |
| 516 | 518 | moves_played++; |
| 517 | 519 | } |
| 518 | | } |
| | 520 | ) |
| 519 | 521 | |
| 520 | 522 | /* Identify unconditionally alive stones and unconditional territory. */ |
| 521 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 523 | scan_board(pos, |
| 522 | 524 | if (board[pos] == color && !potential_sekis[pos]) { |
| 523 | 525 | unconditional_territory[pos] = 1; |
| 524 | 526 | if (find_origin(pos) == pos) { |
| … |
… |
|
| 532 | 534 | findlib(pos, 1, libs); |
| 533 | 535 | unconditional_territory[libs[0]] = 2; |
| 534 | 536 | } |
| 535 | | } |
| | 537 | ) |
| 536 | 538 | |
| 537 | 539 | /* Take back all moves. */ |
| 538 | 540 | while (moves_played > 0) { |