1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see       *
3  * http://www.gnu.org/software/gnugo/ for more information.          *
4  *                                                                   *
5  * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,   *
6  * 2008 and 2009 by the Free Software Foundation.                    *
7  *                                                                   *
8  * This program is free software; you can redistribute it and/or     *
9  * modify it under the terms of the GNU General Public License as    *
10  * published by the Free Software Foundation - version 3 or          *
11  * (at your option) any later version.                               *
12  *                                                                   *
13  * This program is distributed in the hope that it will be useful,   *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     *
16  * GNU General Public License in file COPYING for more details.      *
17  *                                                                   *
18  * You should have received a copy of the GNU General Public         *
19  * License along with this program; if not, write to the Free        *
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,       *
21  * Boston, MA 02111, USA.                                            *
22 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
23 
24 #include "gnugo.h"
25 
26 #include <stdio.h>
27 
28 #include "sgftree.h"
29 #include "liberty.h"
30 #include "config.h"
31 
32 /*
33  * Define all global variables used within the engine.
34  */
35 
36 int thrashing_dragon = NO_MOVE; /* Dead opponent's dragon trying to live. */
37 signed char thrashing_stone[BOARDMAX]; /* All thrashing stones. */
38 
39 float potential_moves[BOARDMAX];
40 
41 /* Used by reading. */
42 int depth;              /* deep reading cut off */
43 int backfill_depth;     /* deep reading cut off */
44 int backfill2_depth;    /* deep reading cut off */
45 int break_chain_depth;  /* deep reading cut off */
46 int superstring_depth;  /* deep reading cut off */
47 int fourlib_depth;      /* deep reading cut off */
48 int ko_depth;           /* deep reading cut off */
49 int branch_depth;       /* deep reading cut off */
50 int aa_depth;
51 int depth_offset;       /* keeps track of temporary depth changes */
52 int owl_distrust_depth;   /* below this owl trusts the optics code */
53 int owl_branch_depth;     /* below this owl tries only one variation */
54 int owl_reading_depth;    /* owl does not read below this depth */
55 int owl_node_limit;       /* maximum number of nodes considered */
56 int semeai_branch_depth;
57 int semeai_branch_depth2;
58 int semeai_node_limit;
59 int connect_depth;	/* Used by Tristan Cazenave's connection reader. */
60 int connect_depth2;     /* Used by alternater connection reader. */
61 int connection_node_limit;
62 int breakin_node_limit; /* Reading limits for break_in/block_off reading */
63 int breakin_depth;
64 /* Mandated values for deep reading cutoffs. */
65 int mandated_depth = -1;
66 int mandated_backfill_depth = -1;
67 int mandated_backfill2_depth = -1;
68 int mandated_break_chain_depth = -1;
69 int mandated_superstring_depth = -1;
70 int mandated_fourlib_depth = -1;
71 int mandated_ko_depth = -1;
72 int mandated_branch_depth = -1;
73 int mandated_aa_depth = -1;
74 int mandated_owl_distrust_depth = -1;
75 int mandated_owl_branch_depth = -1;
76 int mandated_owl_reading_depth = -1;
77 int mandated_owl_node_limit = -1;
78 int mandated_semeai_node_limit = -1;
79 
80 
81 /* Miscellaneous. */
82 int quiet             = 0;  /* minimal output */
83 int showstatistics    = 0;  /* print statistics */
84 int profile_patterns  = 0;  /* print statistics of pattern usage */
85 int allpats           = 0;  /* generate all patterns, even small ones */
86 int printworms        = 0;  /* print full data on each string */
87 int printmoyo         = 0;  /* print moyo board each move */
88 int printboard        = 0;  /* print board each move */
89 int fusekidb          = 1;  /* use fuseki database */
90 int disable_fuseki    = 0;  /* do not generate fuseki moves */
91 int josekidb          = 1;  /* use joseki database */
92 int showtime          = 0;  /* print time to find move */
93 int showscore         = 0;  /* print estimated score */
94 int debug             = 0;  /* controls debug output */
95 int verbose           = 0;  /* trace level */
96 char outfilename[128] = ""; /* output file (-o option) */
97 int output_flags      = OUTPUT_DEFAULT; /* amount of output to outfile */
98 int metamachine       = 0;  /* use metamachine_genmove */
99 int oracle_exists     = 0;  /* oracle is available for consultation   */
100 int autolevel_on      = 0;  /* Adjust level in GMP or ASCII mode. */
101 
102 int disable_threat_computation = 0;
103 int disable_endgame_patterns   = 0;
104 int doing_scoring              = 0;
105 
106 int chinese_rules = CHINESE_RULES; /* ruleset choice for GMP connection */
107 /* use experimental connection module */
108 int experimental_connections = EXPERIMENTAL_CONNECTIONS;
109 /* use alternate connection reading algorithm */
110 int alternate_connections = ALTERNATE_CONNECTIONS;
111 /* compute owl threats */
112 int owl_threats = OWL_THREATS;
113 /* use experimental owl extension (GAIN/LOSS) */
114 int experimental_owl_ext = EXPERIMENTAL_OWL_EXT;
115 /* use experimental territory break-in module */
116 int experimental_break_in = USE_BREAK_IN;
117 /* use central oriented influence */
118 int cosmic_gnugo = COSMIC_GNUGO;
119 /* search for large scale owl moves */
120 int large_scale = LARGE_SCALE;
121 
122 int capture_all_dead    = 0;    /* capture all dead opponent stones */
123 int play_out_aftermath  = 0;    /* make everything unconditionally settled */
124 int resign_allowed = RESIGNATION_ALLOWED; /* resign hopeless games */
125 
126 int play_mirror_go      = 0;    /* try to play mirror go if possible */
127 int mirror_stones_limit = -1;   /* but stop at this number of stones */
128 
129 int gtp_version         = 2;    /* Use GTP version 2 by default. */
130 int use_monte_carlo_genmove = 0; /* Default is not to use Monte Carlo move
131 				  * generation.
132 				  */
133 int mc_games_per_level = 8000;  /* By default, use 8000 times the current
134 				 * level number of simulations
135 				 * for each mmove when Monte Carlo
136 				 * move generation is enabled.
137 				 */
138 
139 float best_move_values[10];
140 int   best_moves[10];
141 float white_score;
142 float black_score;
143 
144 int close_worms[BOARDMAX][4];
145 int number_close_worms[BOARDMAX];
146 int close_black_worms[BOARDMAX][4];
147 int number_close_black_worms[BOARDMAX];
148 int close_white_worms[BOARDMAX][4];
149 int number_close_white_worms[BOARDMAX];
150 
151 int false_eye_territory[BOARDMAX];
152 int forced_backfilling_moves[BOARDMAX];
153 
154 struct worm_data      worm[BOARDMAX];
155 struct dragon_data    dragon[BOARDMAX];
156 int                   number_of_dragons;
157 struct dragon_data2   *dragon2 = NULL;
158 struct half_eye_data  half_eye[BOARDMAX];
159 struct eye_data       black_eye[BOARDMAX];
160 struct eye_data       white_eye[BOARDMAX];
161 struct vital_eye_points black_vital_points[BOARDMAX];
162 struct vital_eye_points white_vital_points[BOARDMAX];
163 struct surround_data  surroundings[MAX_SURROUND];
164 int                   surround_pointer;
165 
166 int cutting_points[BOARDMAX];
167 
168 double slowest_time = 0.0;
169 int    slowest_move = NO_MOVE;
170 int    slowest_movenum = 0;
171 double total_time = 0.0;
172 
173 
174 float minimum_value_weight  = 1.0;
175 float maximum_value_weight  = 1.0;
176 float invasion_malus_weight = 1.0;
177 float territorial_weight    = 1.0;
178 float strategical_weight    = 1.0;
179 float attack_dragon_weight  = 1.0;
180 float followup_weight       = 1.0;
181