[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] arend_1_22.1: minor discard_redundant_move_reasons revisio
From: |
Arend Bayer |
Subject: |
[gnugo-devel] arend_1_22.1: minor discard_redundant_move_reasons revision |
Date: |
Mon, 14 Jan 2002 23:27:17 +0100 (CET) |
- some comments added and a few stylistic changes around
discard_redundant_move_reasons
- unsafe tactical moves now taken care by discard_redundant_move_reasons
- FIXME added for reevaluate_ko_threats
This patch has no effects. It adresses a few comments Gunnar made on
my discard_redundant_move_reasons implementation, adds some comments,
and moves another discard rule from estimate_xxx_value to discard_rules.
-Arend
Index: engine/move_reasons.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v
retrieving revision 1.61
diff -u -r1.61 move_reasons.c
--- engine/move_reasons.c 13 Jan 2002 03:33:22 -0000 1.61
+++ engine/move_reasons.c 14 Jan 2002 21:10:46 -0000
@@ -77,10 +77,10 @@
typedef int (*discard_condition_fn_ptr)(int pos, int what);
struct discard_rule {
- int reason_type[40];
+ int reason_type[MAX_REASONS];
discard_condition_fn_ptr condition;
int flags;
- char trace_message[160];
+ char trace_message[MAX_TRACE_LENGTH];
};
@@ -291,7 +291,9 @@
/* Interprets the object of a reason and returns its position.
* If the object is a pair (of worms or dragons), the position of the first
* object is returned. (This is only used for trace outputs.) Returns
- * -1 if move does not point to a location.
+ * NO_MOVE if move does not point to a location.
+ * FIXME: This new function produces some code duplication with other
+ * trace output function. Do some code cleanup here.
*/
static int
get_pos(int reason, int what)
@@ -338,7 +340,7 @@
case EXPAND_MOYO_MOVE:
case MY_ATARI_ATARI_MOVE:
case YOUR_ATARI_ATARI_MOVE:
- return -1;
+ return NO_MOVE;
}
/* We shoud never get here: */
gg_assert(1>2);
@@ -490,6 +492,10 @@
return 0;
}
+/* ---------------------------------------------------------------- */
+
+/* Functions used in discard_rules follow below. */
+
/*
* Check whether an attack move reason already is recorded for a move.
* A negative value for 'what' means only match 'type'.
@@ -601,6 +607,12 @@
return DRAGON2(dragons[what]).safety == INESSENTIAL;
}
+static int
+move_is_marked_unsafe(int pos, int what)
+{
+ UNUSED(what);
+ return !move[pos].move_safety;
+}
static int
either_move_redundant(int pos, int what)
@@ -1623,6 +1635,8 @@
* The format is:
* { List of reasons to which the rule applies, condition of the rule,
* flags to be set, trace message }
+ * The condition must be of type discard_condition_fn_ptr, that is a pointer
+ * to a function with parameters (pos, what).
*/
static struct discard_rule discard_rules[] =
@@ -1658,6 +1672,10 @@
OWL_DEFEND_MOVE_BAD_KO, UNCERTAIN_OWL_DEFENSE, -1 },
concerns_inessential_dragon, REDUNDANT,
" %1m: 0.0 - (uncertain) owl attack/defense of %1m (inessential)\n"},
+ { { ATTACK_MOVE, ATTACK_MOVE_GOOD_KO, ATTACK_MOVE_BAD_KO,
+ DEFEND_MOVE, DEFEND_MOVE_GOOD_KO, DEFEND_MOVE_BAD_KO, -1},
+ move_is_marked_unsafe, REDUNDANT,
+ " %1m: 0.0 - tactical move vs %1m (unsafe move)\n"},
{ { -1 }, NULL, 0, ""} /* Keep this entry at end of the list. */
};
Index: engine/move_reasons.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.h,v
retrieving revision 1.11
diff -u -r1.11 move_reasons.h
--- engine/move_reasons.h 13 Jan 2002 03:33:22 -0000 1.11
+++ engine/move_reasons.h 14 Jan 2002 21:10:47 -0000
@@ -70,13 +70,15 @@
#define EITHER_MOVE 100
/* Bitmap values for move_reason.status */
-#define ACTIVE 0
-#define TERRITORY_REDUNDANT 1
+#define ACTIVE 0
+#define TERRITORY_REDUNDANT 1
#define STRATEGICALLY_REDUNDANT 2
-#define REDUNDANT 3
-#define SECONDARY 4
+#define REDUNDANT (TERRITORY_REDUNDANT | STRATEGICALLY_REDUNDANT)
+#define SECONDARY 4
#define MAX_REASONS 40
+
+#define MAX_TRACE_LENGTH 160
#define HUGE_MOVE_VALUE 10.0*MAX_BOARD*MAX_BOARD
Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.1
diff -u -r1.1 value_moves.c
--- engine/value_moves.c 13 Jan 2002 15:22:58 -0000 1.1
+++ engine/value_moves.c 14 Jan 2002 21:10:58 -0000
@@ -1090,13 +1090,6 @@
break;
}
- /* Strategically unsafe move. */
- if (!move[pos].move_safety) {
- DEBUG(DEBUG_MOVE_REASONS,
- " %1m: 0.0 - attack on %1m (unsafe move)\n", pos, aa);
- break;
- }
-
this_value = 2 * worm[aa].effective_size;
/* If the stones are dead, there is only a secondary value in
@@ -1142,13 +1135,6 @@
/*
* Estimate value
*/
- if (!strategically_sound_defense(aa, pos)) {
- DEBUG(DEBUG_MOVE_REASONS,
- " %1m: 0.0 - defense of %1m (strategically unsound defense)\n",
- pos, aa);
- break;
- }
-
this_value = 2 * worm[aa].effective_size;
/* If the stones are dead, we use the convention that
@@ -1631,20 +1617,6 @@
if (worm[aa].defend_codes[0] == 0)
break;
- /* Require the defense to be strategically viable. */
- if ((move_reasons[r].type == DEFEND_MOVE
- || move_reasons[r].type == DEFEND_MOVE_GOOD_KO
- || move_reasons[r].type == DEFEND_MOVE_BAD_KO)
- && !strategically_sound_defense(aa, pos))
- break;
-
- /* Do the same for attack moves. */
- if ((move_reasons[r].type == ATTACK_MOVE
- || move_reasons[r].type == ATTACK_MOVE_GOOD_KO
- || move_reasons[r].type == ATTACK_MOVE_BAD_KO)
- && !move[pos].move_safety)
- break;
-
/* FIXME: This is totally ad hoc, just guessing the value of
* potential cutting points.
* FIXME: When worm[aa].cutstone2 == 1 we should probably add
@@ -2333,6 +2305,11 @@
}
+/* This function is called if the biggest move on board was an illegal
+ * ko capture.
+ * FIXME: We need a check here whether the threat still works after
+ * the opponent fills in the ko (or resolves it in another way.)
+ */
static void
reevaluate_ko_threats(void)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] arend_1_22.1: minor discard_redundant_move_reasons revision,
Arend Bayer <=