RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.152
diff -u -r1.152 reading.c
|
|
|
|
| 309 | 309 | int color, const char *funcname, int killer); |
| 310 | 310 | static int simple_ladder_defend(int str, int *move); |
| 311 | 311 | static int in_list(int move, int num_moves, int *moves); |
| | 312 | static int is_single(int pos, int color); |
| 312 | 313 | |
| 313 | 314 | |
| 314 | 315 | /* Statistics. */ |
| … |
… |
|
| 4614 | 4615 | moves->score[k] = -2; |
| 4615 | 4616 | } |
| 4616 | 4617 | |
| | 4618 | static int |
| | 4619 | is_single(int pos, int color) |
| | 4620 | { |
| | 4621 | if ((board[SOUTH(pos)] != color) && (board[EAST(pos)] != color) && |
| | 4622 | (board[WEST(pos)] != color) && (board[NORTH(pos)] != color)) |
| | 4623 | return(1); |
| | 4624 | return(0); |
| | 4625 | } |
| 4617 | 4626 | |
| 4618 | 4627 | /* |
| 4619 | 4628 | * (str) points to a group. |
| … |
… |
|
| 4654 | 4663 | |
| 4655 | 4664 | /* If the 3 liberty chain easily can run away through one of the |
| 4656 | 4665 | * liberties, we don't play on any of the other liberties. |
| | 4666 | * The heuristic for "easily run away" is defined as: |
| | 4667 | * 1. Playing on any of the 3 liberties of the chain and the resulting |
| | 4668 | * number of liberty of the chain will be less than 4. Or |
| | 4669 | * 2. Playing on the 3 liberties in turn will resulting in: |
| | 4670 | * 4 or more liberties, 4 or less liberties and less than |
| | 4671 | * 4 liberties. In this case we only try one breaking chain move |
| | 4672 | * on the position with escape potential of 4 or more liberties. |
| 4657 | 4673 | */ |
| 4658 | 4674 | lib1 = approxlib(libs[0], other, 4, NULL); |
| 4659 | 4675 | lib2 = approxlib(libs[1], other, 4, NULL); |
| 4660 | | if (lib1 >= 4 && lib2 >= 4) |
| 4661 | | continue; |
| 4662 | 4676 | lib3 = approxlib(libs[2], other, 4, NULL); |
| 4663 | 4677 | |
| 4664 | | if ((lib1 >= 4 || lib2 >= 4) && lib3 >= 4) |
| 4665 | | continue; |
| 4666 | | |
| 4667 | 4678 | if (lib1 >= 4 && !mw[libs[0]]) { |
| 4668 | | mw[libs[0]] = 1; |
| 4669 | | possible_moves[u++] = libs[0]; |
| | 4679 | if ((lib2 <= 4 && lib3 < 4) || (lib3 <= 4 && lib2 <4)) |
| | 4680 | { |
| | 4681 | /* For the safety of the breaking chain move, |
| | 4682 | * the move must be either a single stone, or a resulting |
| | 4683 | * string of 4 or more liberties |
| | 4684 | */ |
| | 4685 | if (is_single(libs[0], color) || approxlib(libs[0], color, 4, NULL) > 3) |
| | 4686 | { |
| | 4687 | mw[libs[0]] = 1; |
| | 4688 | possible_moves[u++] = libs[0]; |
| | 4689 | } |
| | 4690 | } |
| 4670 | 4691 | continue; |
| 4671 | 4692 | } |
| 4672 | 4693 | |
| 4673 | 4694 | if (lib2 >= 4 && !mw[libs[1]]) { |
| 4674 | | mw[libs[1]] = 1; |
| 4675 | | possible_moves[u++] = libs[1]; |
| | 4695 | if ((lib1 <= 4 && lib3 < 4) || (lib3 <= 4 && lib1 <4)) |
| | 4696 | { |
| | 4697 | if (is_single(libs[1], color) || approxlib(libs[1], color, 4, NULL) > 3) |
| | 4698 | { |
| | 4699 | mw[libs[1]] = 1; |
| | 4700 | possible_moves[u++] = libs[1]; |
| | 4701 | } |
| | 4702 | } |
| 4676 | 4703 | continue; |
| 4677 | 4704 | } |
| 4678 | 4705 | |
| 4679 | 4706 | if (lib3 >= 4 && !mw[libs[2]]) { |
| 4680 | | mw[libs[2]] = 1; |
| 4681 | | possible_moves[u++] = libs[2]; |
| | 4707 | if ((lib2 <= 4 && lib1 < 4) || (lib1 <= 4 && lib2 <4)) |
| | 4708 | { |
| | 4709 | if (is_single(libs[2], color) || approxlib(libs[2], color, 4, NULL) > 3) |
| | 4710 | { |
| | 4711 | mw[libs[2]] = 1; |
| | 4712 | possible_moves[u++] = libs[2]; |
| | 4713 | } |
| | 4714 | } |
| 4682 | 4715 | continue; |
| 4683 | 4716 | } |
| 4684 | 4717 | |
| | 4718 | if (lib1 >= 4 || lib2 >= 4 || lib3 >= 4) |
| | 4719 | continue; |
| | 4720 | |
| 4685 | 4721 | /* No easy escape, try all liberties. */ |
| 4686 | 4722 | for (k = 0; k < 3; k++) { |
| 4687 | 4723 | if (!mw[libs[k]]) { |