gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Re: Reorientation


From: Teun Burgers
Subject: [gnugo-devel] Re: Reorientation
Date: Wed, 10 Oct 2001 20:23:49 +0200

Teun Burgers wrote:
> 
> This patch makes the gtp reorientation work.

That patch was not correct. It also changed
reading.tst which was not intended.

The attached patch removes the part affecting
reading.tst

Teun
Index: interface/gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp.c,v
retrieving revision 1.6
diff -u -r1.6 gtp.c
--- interface/gtp.c     2001/10/09 23:05:14     1.6
+++ interface/gtp.c     2001/10/10 16:44:12
@@ -176,12 +176,7 @@
       {
        int m = va_arg(ap, int);
        int n = va_arg(ap, int);
-       if (m == -1 && n == -1)
-         fputs("PASS", stdout);
-       else if ((m<0) || (n<0) || (m>=gtp_boardsize) || (n>=gtp_boardsize))
-         fprintf(stdout, "??");
-       else
-         fprintf(stdout, "%c%d", 'A' + n + (n >= 8), gtp_boardsize - m);
+        gtp_print_vertex(m, n);
        break;
       }
       case 'C':
Index: interface/play_gtp.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v
retrieving revision 1.22
diff -u -r1.22 play_gtp.c
--- interface/play_gtp.c        2001/10/09 23:05:14     1.22
+++ interface/play_gtp.c        2001/10/10 16:44:18
@@ -109,6 +109,7 @@
 DECLARE(gtp_captures);
 DECLARE(gtp_protocol_version);
 DECLARE(gtp_query_boardsize);
+DECLARE(gtp_query_orientation);
 DECLARE(gtp_quit);
 DECLARE(gtp_report_uncertainty);
 DECLARE(gtp_reset_life_node_counter);
@@ -117,6 +118,7 @@
 DECLARE(gtp_reset_trymove_counter);
 DECLARE(gtp_same_dragon);
 DECLARE(gtp_set_boardsize);
+DECLARE(gtp_set_orientation);
 DECLARE(gtp_set_komi);
 DECLARE(gtp_set_level);
 DECLARE(gtp_showboard);
@@ -137,6 +139,7 @@
   {"attack",                         gtp_attack},
   {"black",                          gtp_playblack},
   {"boardsize",                      gtp_set_boardsize},
+  {"captures",               gtp_captures},
   {"color",                          gtp_what_color},
   {"combination_attack",      gtp_combination_attack},
   {"connect",                gtp_connect},
@@ -178,9 +181,10 @@
   {"owl_attack",             gtp_owl_attack},
   {"owl_defend",             gtp_owl_defend},
   {"popgo",                          gtp_popgo},
-  {"captures",               gtp_captures},
+  {"orientation",            gtp_set_orientation},
   {"protocol_version",        gtp_protocol_version},
   {"query_boardsize",         gtp_query_boardsize},
+  {"query_orientation",       gtp_query_orientation},
   {"quit",                           gtp_quit},
   {"report_uncertainty",      gtp_report_uncertainty},
   {"reset_life_node_counter", gtp_reset_life_node_counter},
@@ -326,8 +330,43 @@
   return gtp_success(id, "%d", board_size);
 }
 
+/****************************
+ * Setting the orientation. *
+ ****************************/
 
+/* Function:  Set the orienation to N and clear the board
+ * Arguments: integer
+ * Fails:     illegal orientation
+ * Returns:   nothing
+ */
+static int
+gtp_set_orientation(char *s, int id)
+{
+  int orientation;
+  if (sscanf(s, "%d", &orientation) < 1)
+    return gtp_failure(id, "orientation not an integer");
+  
+  if (orientation < 0 || orientation > 7)
+    return gtp_failure(id, "unacceptable orientation");
 
+  clear_board();
+  gtp_internal_set_orientation(orientation);
+  store_position(&starting_position);
+  return gtp_success(id, "");
+}
+
+/* Function:  Find the current orientation
+ * Arguments: none
+ * Fails:     never
+ * Returns:   orientation
+ */
+static int
+gtp_query_orientation(char *s, int id)
+{
+  UNUSED(s);
+
+  return gtp_success(id, "%d", gtp_internal_get_orientation());
+}
 
 /***************************
  * Setting komi.           *
Index: utils/gg_utils.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/utils/gg_utils.c,v
retrieving revision 1.8
diff -u -r1.8 gg_utils.c
--- utils/gg_utils.c    2001/10/09 23:05:14     1.8
+++ utils/gg_utils.c    2001/10/10 16:44:23
@@ -235,6 +235,7 @@
 
 /* Reorientation of point (i,j) into (*ri, *rj) */
 void rotate(int i, int j, int *ri, int *rj, int bs, int rot) {
+  int bs1;
   assert (bs > 0);
   assert (ri != NULL && rj != NULL);
   assert (rot >= 0 && rot < 8);
@@ -247,38 +248,39 @@
   assert (i >= 0 && i < bs);
   assert (j >= 0 && j < bs);
 
+  bs1 = bs - 1;
   if (rot == 0) {
     /* identity map */
     *ri = i;
     *rj = j;
   } else if (rot == 1) {
     /* rotation over 90 degrees */
-    *ri = bs - j;
+    *ri = bs1 - j;
     *rj = i;
   } else if (rot == 2) {
     /* rotation over 180 degrees */
-    *ri = bs - i;
-    *rj = bs - j;
+    *ri = bs1 - i;
+    *rj = bs1 - j;
   } else if (rot == 3) {
     /* rotation over 270 degrees */
     *ri = j;
-    *rj = bs - i;
+    *rj = bs1 - i;
   } else if (rot == 4) {
     /* flip along diagonal */
     *ri = j;
     *rj = i;
   } else if (rot == 5) {
     /* flip */
-    *ri = bs - i;
+    *ri = bs1 - i;
     *rj = j;
   } else if (rot == 6) {
     /* flip along diagonal */
-    *ri = bs - j;
-    *rj = bs - i;
+    *ri = bs1 - j;
+    *rj = bs1 - i;
   } else if (rot == 7) {
     /* flip */
     *ri = i;
-    *rj = bs - j;
+    *rj = bs1 - j;
   }
 }
 


reply via email to

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