#ifndef _THOURT_GO_H_
#define _THOURT_GO_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <math.h>

#define S_BLACK 1
#define S_WHITE -1
#define C  3.1     /* 共立出版 (2012)松原仁　編, 美添一樹 ? 山下宏　著
					  「コンピュータ囲碁　モンテカルロ法の理論と実践」より */
#define PLAYOUT_TIMES 1500/*500*//*1000*//*1500*//*2000*/
#define UCBMAX 1000
#define THRESHOLD 20
#define SPACE 0
#define BLACK 1
#define WHITE -1
#define SENTINEL 3

const int PURE_BOARD_SIZE = 19;  // 盤の大きさ
const int PASS = 0;     // パスに相当する値
const int RESIGN = -1;  // 投了に相当する値

typedef struct node
{
	int   pos;
	int   playout_sum;
	int   win_black;
	int   win_white;
	int   child_num;
	struct node  *next;
	struct node  *parent;
	struct node  *child[1];
} node;

extern int m_pure_board_size;

void SetPlayoutX(int playout);
void SetBoardSizeX(int size);
void ClearBoardX();
void SetKomiX(double new_komi);
void PutStoneX(int pos, int color);
int  UctSearchX(int color);
int  UctAnalyzeX(int color);
int  StringToIntegerX(char *cpos);

node* make_uct();
int expand_node(node* parent, int *pos_array, int ko_pos);
int search_uct(node *node, int color, int size, int *posl);
int verify_legal(int pos, int color, int *posl, int *ko_pos, int update);
int verify_neighbor(int pos, int color, char *check, int *posl, short *n);
int verify_liberty(int pos, int color, char *check, int *posl);
int playout(int color, int size, int *posl, int ko);

#endif
