gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] gtp patch


From: Anthony Hivert
Subject: [gnugo-devel] gtp patch
Date: Thu, 15 Nov 2001 17:53:41 +0100

Hi,
this is our first patch for gnugo.
(please check if everything is ok).

Anthony &
Sebastien





November 13 2001
----------------

Changelog:
        - add a void new_game gtp command for
        compatibility with GTP protocol
        - add optional many gtp undo possibility 
        as specified in GTP protocol.

GTP protocol: http://www.lysator.liu.se/~gunnar/gtp/spec.txt



diff -ru ../gnugo-3.1.13.old/interface/play_gtp.c ./interface/play_gtp.c
--- ../gnugo-3.1.13.old/interface/play_gtp.c    Thu Nov 15 17:18:59 2001
+++ ./interface/play_gtp.c      Thu Nov 15 17:37:37 2001
@@ -102,6 +102,7 @@
 DECLARE(gtp_is_legal);
 DECLARE(gtp_loadsgf);
 DECLARE(gtp_name);
+DECLARE(gtp_new_game);
 DECLARE(gtp_estimate_score);
 DECLARE(gtp_owl_attack);
 DECLARE(gtp_owl_defend);
@@ -180,6 +181,7 @@
   {"level",                  gtp_set_level},
   {"loadsgf",                        gtp_loadsgf},
   {"name",                    gtp_name},
+  {"new_game",                gtp_new_game},
   {"new_score",               gtp_estimate_score},
   {"owl_attack",             gtp_owl_attack},
   {"owl_defend",             gtp_owl_defend},
@@ -267,6 +269,18 @@
   return gtp_success(id, "1");
 }
 
+/* Function:  Start a new game
+ * Arguments: none
+ * Fails:     always
+ * Returns:   nothing
+ */
+static int
+gtp_new_game(char *s, int id)
+{
+  UNUSED(s);
+  return gtp_failure(id, "not implemented");
+}
+
 
 /****************************
  * Program identity.        *
@@ -1355,16 +1369,17 @@
 static int
 gtp_undo(char *s, int id)
 {
-  int k;
-  UNUSED(s);
-
-  if (move_stack_pointer == 0)
+  int k, nb_undo;
+  
+  nb_undo=1;
+  sscanf(s, "%d", &nb_undo);
+  if ((move_stack_pointer-nb_undo) < 0)
     return gtp_failure(id, "no moves to take back");
   if (move_stack_pointer > MAX_MOVES)
     return gtp_failure(id, "move stack overflow");
   restore_position(&starting_position);
-
-  move_stack_pointer--;
+  
+  move_stack_pointer=move_stack_pointer-nb_undo;
   for (k = 0; k < move_stack_pointer; k++)
     play_move(POS(game_move[k].i, game_move[k].j), game_move[k].color);
 

reply via email to

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