Updated README: Equal sign not required with `--mode` flag.
[sgk-go] / engine / influence.h
CommitLineData
7eeb782e
AT
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 <stdio.h>
25#include <stdlib.h>
26#include <assert.h>
27#include <string.h>
28
29#include "liberty.h"
30#include "winsocket.h"
31
32
33/* The cosmic style uses more influence than the defaults attenuation
34 * coefficients !
35 * The "TERR_.."-values are used in the influence computations used
36 * for territory evaluation. (initial_influence with dragons_known,
37 * move_influence)
38 */
39#define DEFAULT_ATTENUATION \
40 (cosmic_importance * 2.7 + (1.0 - cosmic_importance) * 3.0)
41#define TERR_DEFAULT_ATTENUATION \
42 (cosmic_importance * 2.15 + (1.0 - cosmic_importance) * 2.4)
43
44/* Extra damping coefficient for spreading influence diagonally. */
45#define DIAGONAL_DAMPING \
46 (cosmic_importance * 2.5 + (1.0 - cosmic_importance) * 2.0)
47#define TERR_DIAGONAL_DAMPING \
48 (cosmic_importance * 2.5 + (1.0 - cosmic_importance) * 1.7)
49
50
51
52
53
54
55/* Smallest amount of influence that we care about distributing. */
56#define INFLUENCE_CUTOFF 0.02
57
58/* Value in delta_territory_cache indicating that the value has not
59 * been computed. Arbitrary but unattainable.
60 */
61#define NOT_COMPUTED (-2.0 * MAX_BOARD * MAX_BOARD)
62
63/* Maximum number of regions allowed between territory, moyo, and area.
64 * FIXME: This number is vastly exaggerated. Should be possible to
65 * come up with a much better upper bound.
66 */
67#define MAX_REGIONS (3*MAX_BOARD*MAX_BOARD + 1)
68
69#define MAX_INTRUSIONS (2 * MAX_BOARD * MAX_BOARD)
70
71struct intrusion_data
72{
73 int source_pos; /* Stone from which intrusion originates.*/
74 int strength_pos; /* Position of the intrusion influence soure. */
75 float strength;
76 float attenuation;
77};
78
79struct influence_data
80{
81 signed char safe[BOARDMAX];
82
83 float white_influence[BOARDMAX]; /* Accumulated influence. */
84 float black_influence[BOARDMAX]; /* Accumulated influence. */
85 float white_strength[BOARDMAX]; /* Strength of influence source. */
86 float black_strength[BOARDMAX]; /* Strength of influence source. */
87 float white_attenuation[BOARDMAX];
88 float black_attenuation[BOARDMAX];
89 float white_permeability[BOARDMAX];
90 float black_permeability[BOARDMAX];
91
92 int is_territorial_influence; /* 0 only if computing escape_influence.*/
93
94 float territory_value[BOARDMAX];
95 int non_territory[BOARDMAX];
96 int captured;
97
98 int color_to_move; /* Which color is in turn to move. */
99
100 int queue[MAX_BOARD * MAX_BOARD]; /* Points receiving influence. */
101
102 int intrusion_counter;
103 struct intrusion_data intrusions[MAX_INTRUSIONS];
104
105 int id;
106};
107
108/* Typedef for pointer to either of the functions whose_territory(),
109 * whose_loose_territory(), whose_moyo(), and whose_area().
110 */
111typedef int (*owner_function_ptr)(const struct influence_data *q, int pos);
112
113/* Used for tuning game advancement algorythm */
114#define WEIGHT_TERRITORY 10
115#define WEIGHT_MOYO 3
116#define WEIGHT_AREA 1
117
118
119
120/* cosmic_importance is a number between 0.0 and 1.0 ;
121 * when cosmic_importance is 0.0, the default influence
122 * values are used; when cosmic_importance is 1.0, GNU Go
123 * will try to play an influence-oriented fuseki by
124 * over-estimatingthe potential territory values of moyos.
125 * In the current implementation, cosmic_importance decreases
126 * slowly for 19*19 games from 1.0 at move 4 to 0.0 at move 120.
127 */
128float cosmic_importance;
129
130
131/* Used in the whose_moyo() function */
132struct moyo_determination_data
133{
134 float influence_balance;
135 float my_influence_minimum;
136 float opp_influence_maximum;
137};
138
139
140
141
142/*
143 * Local Variables:
144 * tab-width: 8
145 * c-basic-offset: 2
146 * End:
147 */
148