[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] owl stack
From: |
Paul Pogonyshev |
Subject: |
Re: [gnugo-devel] owl stack |
Date: |
Sun, 11 May 2003 00:07:26 -0400 |
User-agent: |
KMail/1.5.9 |
here is the patch.
- do_push_owl() doesn't copy unnecessary fields of local_owl_data anymore
it also removes unused array which i forgot to remove in paul_3_20.5.
no regression breakage.
now profile looks like this:
0.09 811.56 0.79 15903589 0.00 0.00 attack1
0.09 812.32 0.76 189035 0.00 0.00 do_push_owl
0.09 813.07 0.75 9145412 0.00 0.00 attack
-----------------------------------------------
0.02 0.00 5859/189035 do_owl_analyze_semeai [53]
0.74 0.00 183176/189035 push_owl [286]
[284] 0.1 0.76 0.00 189035 do_push_owl [284]
-----------------------------------------------
as i mentioned, it took over 2.5% in my latest profile, but that was for
some 3.3.18 subversion as far as i remember.
Paul
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.157
diff -u -p -r1.157 owl.c
--- engine/owl.c 9 May 2003 22:44:38 -0000 1.157
+++ engine/owl.c 10 May 2003 20:53:19 -0000
@@ -66,6 +66,11 @@
struct local_owl_data {
char goal[BOARDMAX];
char boundary[BOARDMAX];
+
+ /* FIXME: escape_values[] are never recomputed. Consider moving this array
+ * from stack to a static or dynamic variable so it is not copied
+ * around in do_push_owl(). Be aware of semeai code though.
+ */
char escape_values[BOARDMAX];
int color;
@@ -84,7 +89,7 @@ struct local_owl_data {
char safe_move_cache[BOARDMAX];
- /* This is used to organize the owl stack. */
+ /* This is used to organize the owl stack. */
int restore_from;
int number_in_stack;
};
@@ -796,8 +801,6 @@ do_owl_analyze_semeai(int apos, int bpos
push_owl(&owla, &owlb);
owl_update_goal(mpos, moves[k].same_dragon, owla, 1);
- owla->lunches_are_current = 0;
- owlb->lunches_are_current = 0;
owl_update_boundary_marks(mpos, owlb);
if (board[bpos] == EMPTY) {
@@ -1615,7 +1618,6 @@ do_owl_attack(int str, int *move, int *w
push_owl(&owl, NULL);
mw[mpos] = 1;
number_tried_moves++;
- owl->lunches_are_current = 0;
owl_update_boundary_marks(mpos, owl);
/* If the origin of the dragon has been captured, we look
@@ -2196,7 +2198,6 @@ do_owl_defend(int str, int *move, int *w
push_owl(&owl, NULL);
mw[mpos] = 1;
number_tried_moves++;
- owl->lunches_are_current = 0;
/* Add the stone just played to the goal dragon, unless the
* pattern explicitly asked for not doing this.
@@ -4499,7 +4500,6 @@ improve_lunch_attack(int lunch, int atta
int color = OTHER_COLOR(board[lunch]);
int defense_point;
int k;
- int adj[MAXCHAIN];
if (safe_move(attack_point, color)) {
if (is_edge_vertex(lunch)
@@ -5258,19 +5258,27 @@ init_owl(struct local_owl_data **owl, in
static void
do_push_owl(struct local_owl_data **owl)
{
+ struct local_owl_data *new_owl = &owl_stack[++owl_stack_pointer];
+
gg_assert(&owl_stack[(*owl)->number_in_stack] == *owl);
/* Copy the owl data. */
- owl_stack_pointer++;
- owl_stack[owl_stack_pointer] = **owl;
+ memcpy(new_owl->goal, (*owl)->goal, sizeof(new_owl->goal));
+ memcpy(new_owl->boundary, (*owl)->boundary, sizeof(new_owl->boundary));
+ memcpy(new_owl->escape_values, (*owl)->escape_values,
+ sizeof(new_owl->escape_values));
+ new_owl->color = (*owl)->color;
+
+ new_owl->lunches_are_current = 0;
/* Needed for stack organization: */
- owl_stack[owl_stack_pointer].number_in_stack = owl_stack_pointer;
- owl_stack[owl_stack_pointer].restore_from = (*owl)->number_in_stack;
+ new_owl->number_in_stack = owl_stack_pointer;
+ new_owl->restore_from = (*owl)->number_in_stack;
/* Finally move the *owl pointer. */
- *owl = &owl_stack[owl_stack_pointer];
+ *owl = new_owl;
}
+
/* Push owl data one step upwards in the stack. The stack is dynamically
* reallocated if it is too small. Second argument is used from the