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 /* values for move_reason.type */ 25 #define THREAT_BIT 1 26 27 /* Only use even values for non-threat move reasons! */ 28 #define ATTACK_MOVE 2 29 #define ATTACK_MOVE_GOOD_KO 4 30 #define ATTACK_MOVE_BAD_KO 6 31 #define ATTACK_THREAT (ATTACK_MOVE | THREAT_BIT) 32 #define DEFEND_MOVE 8 33 #define DEFEND_MOVE_GOOD_KO 10 34 #define DEFEND_MOVE_BAD_KO 12 35 #define DEFEND_THREAT (DEFEND_MOVE | THREAT_BIT) 36 37 #define CONNECT_MOVE 14 38 #define CUT_MOVE 16 39 40 #define SEMEAI_MOVE 18 41 #define SEMEAI_THREAT (SEMEAI_MOVE | THREAT_BIT) 42 43 #define EXPAND_TERRITORY_MOVE 20 44 #define EXPAND_MOYO_MOVE 22 45 #define INVASION_MOVE 24 46 47 #define OWL_ATTACK_MOVE 26 48 #define OWL_ATTACK_MOVE_GOOD_KO 28 49 #define OWL_ATTACK_MOVE_BAD_KO 30 50 #define OWL_ATTACK_THREAT (OWL_ATTACK_MOVE | THREAT_BIT) 51 #define OWL_DEFEND_MOVE 32 52 #define OWL_DEFEND_MOVE_GOOD_KO 34 53 #define OWL_DEFEND_MOVE_BAD_KO 36 54 #define OWL_DEFEND_THREAT (OWL_DEFEND_MOVE | THREAT_BIT) 55 #define OWL_PREVENT_THREAT 38 56 #define UNCERTAIN_OWL_ATTACK 40 57 #define UNCERTAIN_OWL_DEFENSE 42 58 #define STRATEGIC_ATTACK_MOVE 44 59 #define STRATEGIC_DEFEND_MOVE 46 60 61 #define MY_ATARI_ATARI_MOVE 50 62 #define YOUR_ATARI_ATARI_MOVE 52 63 #define VITAL_EYE_MOVE 54 64 65 #define OWL_ATTACK_MOVE_GAIN 60 66 #define OWL_DEFEND_MOVE_LOSS 62 67 #define POTENTIAL_SEMEAI_ATTACK 64 68 #define POTENTIAL_SEMEAI_DEFENSE 66 69 70 #define ANTISUJI_MOVE 70 71 72 #define EITHER_MOVE 100 73 #define ALL_MOVE 102 74 75 76 /* Bitmap values for move_reason.status */ 77 #define ACTIVE 0 78 #define TERRITORY_REDUNDANT 1 79 #define STRATEGICALLY_REDUNDANT 2 80 #define REDUNDANT (TERRITORY_REDUNDANT | STRATEGICALLY_REDUNDANT) 81 #define SECONDARY 4 82 83 #define MAX_REASONS 120 84 85 #define MAX_TRACE_LENGTH 160 86 87 #define HUGE_MOVE_VALUE 10.0*MAX_BOARD*MAX_BOARD 88 89 struct move_reason { 90 int type; /* e.g. attack, defend, or connect */ 91 int what; /* pointer into list of strings, list of pair of dragons, 92 or similar */ 93 int status; /* This is a bitmap to mark redundant or secondary 94 move reasons. */ 95 }; 96 97 struct move_data { 98 float value; /* total comparison value, computed at the very end */ 99 float final_value; /* value after point redistribution. */ 100 float additional_ko_value; /* Additional threat value if ko fight going on.*/ 101 102 float territorial_value; /* Value in terms of actual profit. */ 103 float strategical_value; /* Value with respect to strength, weakness, and 104 safety of all groups on the board. */ 105 106 float maxpos_shape; /* Maximal positive contribution to shape */ 107 float maxneg_shape; /* Maximal negative contribution to shape */ 108 int numpos_shape; /* Number of positive contributions to shape */ 109 int numneg_shape; /* Number of negative contributions to shape */ 110 111 float followup_value; /* Value of followup move (our sente). */ 112 float influence_followup_value; /* Followup value of move as reported by 113 experimental influence. */ 114 float reverse_followup_value; /* Value of opponents followup move 115 (reverse sente). */ 116 float secondary_value; /* Secondary move value. */ 117 float min_value; /* Minimum allowed value for the move. */ 118 float max_value; /* Maximum allowed value for the move. */ 119 float min_territory; /* Minimum territorial value. */ 120 float max_territory; /* Maximum territorial value. */ 121 float randomness_scaling; /* Increase to randomize this move. */ 122 123 int reason[MAX_REASONS]; /* List of reasons for a move. */ 124 int move_safety; /* Whether the move seems safe. */ 125 int worthwhile_threat; /* Play this move as a pure threat. */ 126 float random_number; /* Random number connected to this move. */ 127 }; 128 129 130 131 /* 132 * Some sizes. 133 * 134 * FIXME: Many of these could be optimized more for size (e.g. MAX_EYES) 135 */ 136 137 #define MAX_MOVE_REASONS 1000 138 #define MAX_WORMS 2*MAX_BOARD*MAX_BOARD/3 139 #define MAX_DRAGONS MAX_WORMS 140 #define MAX_CONNECTIONS 4*MAX_WORMS 141 #define MAX_POTENTIAL_SEMEAI 50 142 #define MAX_EYES MAX_BOARD*MAX_BOARD/2 143 #define MAX_LUNCHES MAX_WORMS 144 #define MAX_EITHER 100 145 #define MAX_ALL 100 146 #define MAX_ATTACK_THREATS 6 147 148 149 extern struct move_data move[BOARDMAX]; 150 extern struct move_reason move_reasons[MAX_MOVE_REASONS]; 151 extern int next_reason; 152 153 /* Connections */ 154 extern int conn_worm1[MAX_CONNECTIONS]; 155 extern int conn_worm2[MAX_CONNECTIONS]; 156 extern int next_connection; 157 158 extern int semeai_target1[MAX_POTENTIAL_SEMEAI]; 159 extern int semeai_target2[MAX_POTENTIAL_SEMEAI]; 160 161 /* Unordered sets (currently pairs) of move reasons / targets */ 162 typedef struct { 163 int reason1; 164 int what1; 165 int reason2; 166 int what2; 167 } Reason_set; 168 extern Reason_set either_data[MAX_EITHER]; 169 extern int next_either; 170 extern Reason_set all_data[MAX_ALL]; 171 extern int next_all; 172 173 /* Eye shapes */ 174 extern int eyes[MAX_EYES]; 175 extern int eyecolor[MAX_EYES]; 176 extern int next_eye; 177 178 /* Lunches */ 179 extern int lunch_dragon[MAX_LUNCHES]; /* eater */ 180 extern int lunch_worm[MAX_LUNCHES]; /* food */ 181 extern int next_lunch; 182 183 /* Point redistribution */ 184 extern int replacement_map[BOARDMAX]; 185 186 /* The color for which we are evaluating moves. */ 187 extern int current_color; 188 189 int find_worm(int str); 190 int find_dragon(int str); 191 192 int move_reason_known(int pos, int type, int what); 193 int attack_move_reason_known(int pos, int what); 194 int defense_move_reason_known(int pos, int what); 195 int owl_attack_move_reason_known(int pos, int what); 196 int owl_defense_move_reason_known(int pos, int what); 197 int owl_move_reason_known(int pos, int what); 198 int semeai_move_reason_known(int pos, int what); 199 int get_biggest_owl_target(int pos); 200 int is_antisuji_move(int pos); 201 202 void discard_redundant_move_reasons(int pos); 203 204 void mark_changed_dragon(int pos, int color, int affected, int affected2, 205 int move_reason_type, 206 signed char safe_stones[BOARDMAX], 207 float strength[BOARDMAX], float *effective_size); 208 void mark_changed_string(int affected, signed char changed_stones[BOARDMAX], 209 float strength[BOARDMAX], signed char new_status); 210 int adjacent_to_nondead_stone(int pos, int color); 211 212 int find_connection(int worm1, int worm2); 213 214 /* 215 * Local Variables: 216 * tab-width: 8 217 * c-basic-offset: 2 218 * End: 219 */ 220 221