gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] undo speed - revised


From: Paul Pogonyshev
Subject: [gnugo-devel] undo speed - revised
Date: Fri, 28 Mar 2003 16:55:41 +0200
User-agent: KMail/1.4.3

the version below must be safer (one line changed: avoid string[]
array overflow).

Paul


--- engine/board.c.orig 2003-03-24 01:55:22.000000000 +0200
+++ engine/board.c      2003-03-24 02:35:10.000000000 +0200
@@ -914,8 +914,16 @@ remove_stone(int pos)
   new_position();
 }
 
+
+/* Play a move. Basically the same as play_move() below, but doesn't store
+ * the move in history list.
+ *
+ * Set `update_internals' to zero if you want to play several moves in a
+ * row to avoid overhead caused by new_position(). Don't forget to call
+ * it yourself after all the moves have been played.
+ */
 static void
-play_move_no_history(int pos, int color)
+play_move_no_history(int pos, int color, int update_internals)
 {
 #if CHECK_HASHING
   Hash_data oldkey;
@@ -951,7 +959,11 @@ play_move_no_history(int pos, int color)
 #endif
 #endif
   }
-  new_position();
+
+  if (update_internals || next_string == MAX_STRINGS)
+    new_position();
+  else
+    CLEAR_STACKS();
 }
 
 /* Load the initial position and replay the first n moves. */
@@ -967,7 +979,9 @@ replay_move_history(int n)
   new_position();
 
   for (k = 0; k < n; k++)
-    play_move_no_history(move_history_pos[k], move_history_color[k]);
+    play_move_no_history(move_history_pos[k], move_history_color[k], 0);
+
+  new_position();
 }
 
 /* Play a move. If you want to test for legality you should first call
@@ -1028,7 +1042,7 @@ play_move(int pos, int color)
   move_history_pos[move_history_pointer] = pos;
   move_history_pointer++;
   
-  play_move_no_history(pos, color);
+  play_move_no_history(pos, color, 1);
   
   movenum++;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]