File: influence.h

package info (click to toggle)
gnugo 3.8-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 17,312 kB
  • ctags: 4,228
  • sloc: ansic: 56,439; perl: 3,771; lisp: 2,789; sh: 730; makefile: 700; python: 682; awk: 113; sed: 22
file content (148 lines) | stat: -rw-r--r-- 5,048 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see       *
 * http://www.gnu.org/software/gnugo/ for more information.          *
 *                                                                   *
 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,   *
 * 2008 and 2009 by the Free Software Foundation.                    *
 *                                                                   *
 * This program is free software; you can redistribute it and/or     *
 * modify it under the terms of the GNU General Public License as    *
 * published by the Free Software Foundation - version 3 or          *
 * (at your option) any later version.                               *
 *                                                                   *
 * This program is distributed in the hope that it will be useful,   *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     *
 * GNU General Public License in file COPYING for more details.      *
 *                                                                   *
 * You should have received a copy of the GNU General Public         *
 * License along with this program; if not, write to the Free        *
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,       *
 * Boston, MA 02111, USA.                                            *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>

#include "liberty.h"
#include "winsocket.h"


/* The cosmic style uses more influence than the defaults attenuation 
 * coefficients !
 * The "TERR_.."-values are used in the influence computations used
 * for territory evaluation. (initial_influence with dragons_known,
 * move_influence)
 */
#define DEFAULT_ATTENUATION \
       	(cosmic_importance * 2.7  + (1.0 - cosmic_importance) * 3.0)
#define TERR_DEFAULT_ATTENUATION \
	(cosmic_importance * 2.15 + (1.0 - cosmic_importance) * 2.4)

/* Extra damping coefficient for spreading influence diagonally. */
#define DIAGONAL_DAMPING \
	(cosmic_importance * 2.5 + (1.0 - cosmic_importance) * 2.0)
#define TERR_DIAGONAL_DAMPING \
	(cosmic_importance * 2.5 + (1.0 - cosmic_importance) * 1.7)






/* Smallest amount of influence that we care about distributing. */
#define INFLUENCE_CUTOFF 0.02

/* Value in delta_territory_cache indicating that the value has not
 * been computed. Arbitrary but unattainable.
 */
#define NOT_COMPUTED (-2.0 * MAX_BOARD * MAX_BOARD)

/* Maximum number of regions allowed between territory, moyo, and area.
 * FIXME: This number is vastly exaggerated. Should be possible to
 * come up with a much better upper bound.
 */ 
#define MAX_REGIONS (3*MAX_BOARD*MAX_BOARD + 1)

#define MAX_INTRUSIONS (2 * MAX_BOARD * MAX_BOARD)

struct intrusion_data
{
  int source_pos; 	/* Stone from which intrusion originates.*/
  int strength_pos;     /* Position of the intrusion influence soure. */
  float strength;
  float attenuation;
};

struct influence_data
{
  signed char safe[BOARDMAX];

  float white_influence[BOARDMAX]; 	/* Accumulated influence. */
  float black_influence[BOARDMAX]; 	/* Accumulated influence. */
  float white_strength[BOARDMAX];  	/* Strength of influence source. */
  float black_strength[BOARDMAX];  	/* Strength of influence source. */
  float white_attenuation[BOARDMAX]; 
  float black_attenuation[BOARDMAX];
  float white_permeability[BOARDMAX];
  float black_permeability[BOARDMAX];

  int is_territorial_influence; /* 0 only if computing escape_influence.*/

  float territory_value[BOARDMAX];
  int non_territory[BOARDMAX];
  int captured;

  int color_to_move; /* Which color is in turn to move. */
  
  int queue[MAX_BOARD * MAX_BOARD];     /* Points receiving influence. */

  int intrusion_counter;
  struct intrusion_data intrusions[MAX_INTRUSIONS];

  int id;
};

/* Typedef for pointer to either of the functions whose_territory(),
 * whose_loose_territory(), whose_moyo(), and whose_area().
 */
typedef int (*owner_function_ptr)(const struct influence_data *q, int pos);

/* Used for tuning game advancement algorythm */
#define WEIGHT_TERRITORY 10
#define WEIGHT_MOYO       3
#define WEIGHT_AREA       1



/* cosmic_importance is a number between 0.0 and 1.0 ;
 * when cosmic_importance is 0.0, the default influence
 * values are used; when cosmic_importance is 1.0, GNU Go
 * will try to play an influence-oriented fuseki by 
 * over-estimatingthe potential territory values of moyos.
 * In the current implementation, cosmic_importance decreases 
 * slowly for 19*19 games from 1.0 at move 4 to 0.0 at move 120.
 */
float cosmic_importance;


/* Used in the whose_moyo() function */
struct moyo_determination_data
{
  float influence_balance;
  float my_influence_minimum;
  float opp_influence_maximum;
};




/*
 * Local Variables:
 * tab-width: 8
 * c-basic-offset: 2
 * End:
 */