[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [gnugo-devel] a patch from a newbie :)
From: |
Portela Fernand |
Subject: |
RE: [gnugo-devel] a patch from a newbie :) |
Date: |
Tue, 10 Sep 2002 19:25:40 +0200 |
Gunnar wrote:
> The new result codes certainly require discussion. In the mean time we
> would, as Arend has commented, be happy to get a partial patch doing
> the following:
>
> * Change 1, 2, 3 to KO_B, KO_A, WIN wherever those macros are
> appropriate.
> * Change any occurences of the form "3 - code" or "WIN - code" to
> "REVERSE_RESULT(code)".
No traces of the use of the literals 1 or 2 in place of KO_?.
(cosmetic patch below)
> The reason why we have a magic gtp_print_code() function is that the
> result codes in the GTP output for historic reasons are
> 0 - failure (0)
> 1 - WIN
> 2 - KO_A
> 3 - KO_B
>
> If we add 2 new result codes we would want to call them 4 and 5
> regardless of their relative value or internal representation. So
> instead of changing a lot of codes in the regression files you should
> add some complexity to the gtp_print_code() function.
Ok, noted. I simply was not aware of this.
/nando
diff -u -r 3.3.8/engine/filllib.c 3.3.8-patch/engine/filllib.c
--- 3.3.8/engine/filllib.c 2002-09-05 01:19:18.000000000 +0200
+++ 3.3.8-patch/engine/filllib.c 2002-09-10 03:35:20.000000000 +0200
@@ -58,12 +58,12 @@
case EMPTY:
if (!(*found_black)
&& living_neighbor(pos, BLACK)
- && safe_move(pos, WHITE) != 3)
+ && safe_move(pos, WHITE) != WIN)
*found_black = 1;
if (!(*found_white)
&& living_neighbor(pos, WHITE)
- && safe_move(pos, BLACK) != 3)
+ && safe_move(pos, BLACK) != WIN)
*found_white = 1;
break;
diff -u -r 3.3.8/engine/owl.c 3.3.8-patch/engine/owl.c
--- 3.3.8/engine/owl.c 2002-09-05 01:19:18.000000000 +0200
+++ 3.3.8-patch/engine/owl.c 2002-09-10 19:10:58.000000000 +0200
@@ -3631,12 +3631,12 @@
if (search_persistent_owl_cache(OWL_ATTACK, origin, 0, 0,
&result, NULL, NULL, NULL)) {
popgo();
- return 3 - result;
+ return REVERSE_RESULT(result);
}
init_owl(&owl, target, NO_MOVE, move, 1);
acode = do_owl_attack(target, NULL, owl, EMPTY, 0, 0);
- result = 3 - acode;
+ result = REVERSE_RESULT(acode);
popgo();
}
else
@@ -3773,7 +3773,7 @@
if (search_persistent_owl_cache(OWL_DEFEND, origin, 0, 0,
&result, NULL, NULL, NULL)) {
popgo();
- return 3 - result;
+ return REVERSE_RESULT(result);
}
#if 0
@@ -3792,7 +3792,7 @@
dcode = 0;
else
dcode = do_owl_defend(target, NULL, owl, EMPTY, 0, 0);
- result = 3 - dcode;
+ result = REVERSE_RESULT(dcode);
owl->lunches_are_current = 0;
popgo();
}
diff -u -r 3.3.8/engine/reading.c 3.3.8-patch/engine/reading.c
--- 3.3.8/engine/reading.c 2002-08-26 01:48:18.000000000 +0200
+++ 3.3.8-patch/engine/reading.c 2002-09-10 19:10:58.000000000 +0200
@@ -2888,7 +2888,7 @@
SGFTRACE(moves[k].pos, 0, "Too deep, aborting attack");
}
/* This defense assignment may be incorrect. */
- other_tactic = gg_max(other_tactic, WIN - same_tactic);
+ other_tactic = gg_max(other_tactic, REVERSE_RESULT(same_tactic));
}
if (!other_tactic) {
if (ko_move) {
@@ -2934,9 +2934,9 @@
/* FIXME: Add explicit attack/defense verbage here. */
- SGFTRACE(best_move, WIN - best_other_tactic, "No good tactic.");
+ SGFTRACE(best_move, REVERSE_RESULT(best_other_tactic), "No good
tactic.");
*move = best_move;
- return WIN - best_other_tactic;
+ return REVERSE_RESULT(best_other_tactic);
}
#endif /*EXPERIMENTAL_READING*/
diff -u -r 3.3.8/engine/worm.c 3.3.8-patch/engine/worm.c
--- 3.3.8/engine/worm.c 2002-09-05 01:19:18.000000000 +0200
+++ 3.3.8-patch/engine/worm.c 2002-09-10 19:10:44.000000000 +0200
@@ -1565,11 +1565,11 @@
* possible that it only has a ko defense and then we would
* risk to find an irrelevant move to attack with ko.
*/
- if (dcode != WIN && 3 - dcode >= worm[str].attack_codes[0]) {
- change_attack(str, move, 3 - dcode);
+ if (dcode != WIN && REVERSE_RESULT(dcode) >=
worm[str].attack_codes[0]) {
+ change_attack(str, move, REVERSE_RESULT(dcode));
DEBUG(DEBUG_WORMS,
"Attack pattern %s+%d found attack on %1m at %1m with code
%d\n",
- pattern->name, ll, str, move, 3 - dcode);
+ pattern->name, ll, str, move, REVERSE_RESULT(dcode));
}
}
}
@@ -1635,10 +1635,10 @@
popgo();
if (acode < worm[str].attack_codes[0]) {
- change_defense(str, move, 3 - acode);
+ change_defense(str, move, REVERSE_RESULT(acode));
DEBUG(DEBUG_WORMS,
"Defense pattern %s+%d found defense of %1m at %1m with code
%d\n",
- pattern->name, ll, str, move, 3 - acode);
+ pattern->name, ll, str, move, REVERSE_RESULT(acode));
}
}
}
RE: [gnugo-devel] a patch from a newbie :), Portela Fernand, 2002/09/12