gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] orientation and --decide* options


From: Teun Burgers
Subject: [gnugo-devel] orientation and --decide* options
Date: Wed, 31 Oct 2001 20:38:24 +0100

In order to make analysis of reoriented tests possible,
this patch makes the --decide* options use the
new --orientation option. The --orientation option
is a synonym for --gtp-initial-orientation.

As a side effect gnugo can be used with the --printsgf
option to reorient game records

gnugo -l game.sgf --orient n --printsgf game_rot.sgf

- new command-line option --orientation
- -l and decide-* options can be combined with --orientation

Teun
Index: main.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- main.c      2001/10/17 00:07:11     1.11
+++ main.c      2001/10/31 19:30:22
@@ -51,6 +51,7 @@
 #include <liberty.h>
 
 #include "gg-getopt.h"
+#include <gg_utils.h>
 
 #include "interface.h"
 #include "gmp.h"
@@ -150,6 +151,7 @@
   {"quiet",          no_argument,       0, OPT_QUIET},
   {"silent",         no_argument,       0, OPT_QUIET},
   {"gtp-input",      required_argument, 0, OPT_GTP_INPUT},
+  {"orientation",    required_argument, 0, OPT_GTP_INITIAL_ORIENTATION},
   {"gtp-initial-orientation",
                     required_argument, 0, OPT_GTP_INITIAL_ORIENTATION},
   {"infile",         required_argument, 0, 'l'},
@@ -246,7 +248,7 @@
   int benchmark = 0;  /* benchmarking mode (-b) */
   float komi = 0.0;
   FILE *gtp_input_FILE;
-  int gtp_initial_orientation = 0;
+  int orientation = 0;
   
   int seed = 0;      /* If seed is zero, GNU Go will play a different game 
                        each time. If it is set using -r, GNU Go will play the
@@ -347,10 +349,9 @@
        break;
        
       case OPT_GTP_INITIAL_ORIENTATION:
-       gtp_initial_orientation = atoi(gg_optarg);
-       if (gtp_initial_orientation < 0 || gtp_initial_orientation > 7) {
-         fprintf(stderr, "Illegal orientation: %d.\n",
-                  gtp_initial_orientation);
+       orientation = atoi(gg_optarg);
+       if (orientation < 0 || orientation > 7) {
+         fprintf(stderr, "Illegal orientation: %d.\n", orientation);
          fprintf(stderr, "Try `gnugo --help' for more information.\n");
          exit(EXIT_FAILURE);
        }
@@ -774,7 +775,8 @@
 
       gameinfo_load_sgfheader(&gameinfo, sgftree.root);
       sgffile_write_gameinfo(&gameinfo, "load and print"); 
-      to_move = gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      to_move = gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                                       untilstring, orientation);
       sgffile_close_file();
       sgffile_open_file(printsgffile);
       sgffile_write_gameinfo(&gameinfo, "load and print"); 
@@ -791,7 +793,8 @@
        return (EXIT_FAILURE);
       }
       
-      gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                               untilstring, orientation);
       boardsize = gameinfo.position.boardsize;
       
       if (!string_to_location(boardsize, decide_this, &m, &n)) {
@@ -799,6 +802,7 @@
        return (EXIT_FAILURE);
       }
 
+      rotate(m, n, &m, &n, boardsize, orientation);
       decidestring(m, n, outfile);
     }
   break;
@@ -812,7 +816,8 @@
        return (EXIT_FAILURE);
       }
       
-      gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                               untilstring, orientation);
       boardsize = gameinfo.position.boardsize;
       
       if (!string_to_location(boardsize, decide_this, &ai, &aj)) {
@@ -825,6 +830,8 @@
        return (EXIT_FAILURE);
       }
 
+      rotate(ai, aj, &ai, &aj, boardsize, orientation);
+      rotate(bi, bj, &bi, &bj, boardsize, orientation);
       decideconnection(ai, aj, bi, bj, outfile);
     }
   break;
@@ -838,7 +845,8 @@
        return (EXIT_FAILURE);
       }
       
-      gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                               untilstring, orientation);
       boardsize = gameinfo.position.boardsize;
       
       if (!string_to_location(boardsize, decide_this, &m, &n)) {
@@ -846,6 +854,7 @@
        return (EXIT_FAILURE);
       }
 
+      rotate(m, n, &m, &n, boardsize, orientation);
       decidedragon(m, n, outfile);
     }
     break;
@@ -859,7 +868,8 @@
        return (EXIT_FAILURE);
       }
       
-      gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                               untilstring, orientation);
       boardsize = gameinfo.position.boardsize;
       
       if (!string_to_location(boardsize, decide_this, &ai, &aj)) {
@@ -872,6 +882,8 @@
        return (EXIT_FAILURE);
       }
 
+      rotate(ai, aj, &ai, &aj, boardsize, orientation);
+      rotate(bi, bj, &bi, &bj, boardsize, orientation);
       decidesemeai(ai, aj, bi, bj, outfile);
     }
     break;
@@ -884,7 +896,8 @@
        fprintf(stderr, "gnugo: --decide-position must be used with -l\n");
        return (EXIT_FAILURE);
       }
-      color=gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      color=gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+                                       untilstring, orientation);
       decideposition(color, outfile);
     }
     break;
@@ -898,7 +911,8 @@
        return (EXIT_FAILURE);
       }
       
-      gameinfo_play_sgftree(&gameinfo, sgftree.root, untilstring);
+      gameinfo_play_sgftree_rot(&gameinfo, sgftree.root,
+               untilstring, orientation);
       boardsize = gameinfo.position.boardsize;
       
       if (!string_to_location(boardsize, decide_this, &m, &n)) {
@@ -906,6 +920,7 @@
        return (EXIT_FAILURE);
       }
       
+      rotate(m, n, &m, &n, boardsize, orientation);
       decideeye(m, n, outfile);
     }
     break;
@@ -924,7 +939,7 @@
     else
       gtp_input_FILE = stdin;
 
-    play_gtp(gtp_input_FILE, gtp_initial_orientation);
+    play_gtp(gtp_input_FILE, orientation);
     break;
 
   case MODE_ASCII_EMACS:  

reply via email to

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