資源簡介
Gomoku AI including Minimax, Heuristic Evaluation, Alpha-Beta Pruning, pre-evaluate, Iterative Deepening, VCT/VCF, PVS, killer heuristic search, dynamic multi-thread(not very dynamic).
Renju rule
代碼片段和文件信息
/*
?Gomoku?AI?including?Minimax?Heuristic?Evaluation?Alpha-Beta?Pruning?pre-evaluate?Iterative?Deepening?VCT/VCF?PVS
?killer?heuristic?search?High?Expectation?Test(invented?by?myself)?dynamic?multi-thread(not?very?dynamic)
Writtern?by?Liv
?*/
#include
#include
#include
#include
#include
#pragma?comment(lib“pthreadVC2.lib“)
#define?max(xy)?((x)>(y)?(x):(y))
#define?min(xy)?((x)<(y)?(x):(y))
#define?abs(x)?(((x)>=0)?(x):(-(x)))
#define?BOARD_SIZE??15
#define?NO_CHESS????“┼“
#define?BLACK_CHESS???“○“
#define?WHITE_CHESS???“●“
#define?CURRENT_BLACK “△“
#define?CURRENT_WHITE “▲“
#define?DEPTH?8???//the?depth?of?Minimax
#define?FIVE?100000
#define?ALIVE_FOUR?50000
#define?RUSH_FOUR?2000
#define?ALIVE_THREE?2000
#define?RUSH_THREE?200
#define?ALIVE_TWO?200
#define?RUSH_TWO?20
#define?ALIVE_ONE?1
#define?NOW_WIN?10000000
#define?ONE_WIN?1000000
#define?OCCUPIED?-200000000
#define?INITIAL?-300000000
#define?HASH_SIZE?262144???//power(218)
#define?PVS_PARAMETER?3
#define?HET_PARAMETER?2500
#define?PVS_MAX?20 //most?considerd?point?nunmber
#define?THREAD_NUMBER?4
#define?LOCK_SIZE?4096 //power(212)
struct?can{ //candidate?move?point
????int?value;
????int?xp;?//x?position
????int?yp;?//y?position
????int?count[4][7];???//AI?part?alive_fourrush_fouralive_threerush_threealive_tworush_twoalive_one?for?4?orientation
????int?ver_count[4][7];???//human?part?alive_fourrush_fouralive_threerush_threealive_tworush_twoalive_one?for?4?orientation
????int?sum[2][7];??//0?for?AI?1?for?human
};
struct?lines{ //record?pattern?such?as?alive?four
????int?rowline[2][BOARD_SIZE][7];?????//alive_fourrush_fouralive_threerush_threealive_tworush_twoalive_one?0?for?AI?1?for?human //row
????int?colline[2][BOARD_SIZE][7]; //column
????int?lcolline[2][2*BOARD_SIZE-1][7]; //from?(min_xmin_y)?to?(max_xmax_y)
????int?rcolline[2][2*BOARD_SIZE-1][7]; //from?(min_xmax_y)?to?(max_xmin_y)
????int?sum[2][7]; //sum?four?orientation
};
struct?para_func{ //parameter?for?function?MultiThread_Minimax?in?consider?of?multi-thread?design
????int?(*Che_Val)[BOARD_SIZE]; //digital?chess?board
????int?*b_i; //candidate?i
????int?colo; //color
????int?depth;
????int?*best; //now?best?sore
????int?*b_x*b_y; //position?of?best?point
????int?*pvs; //pvs?number
????int?whe_main_thread;????//whether?it?is?main?thread
????unsigned?long?long?int?chara; //character?code
????struct?can?*candi;
????struct?lines*?count;
};
char?*Chess[BOARD_SIZE][BOARD_SIZE];??//storage?chesses
int?Chess_Val[THREAD_NUMBER][BOARD_SIZE][BOARD_SIZE];??//value?of?chess?1?for?black?1000?for?white
int?Chess_Val_pon[THREAD_NUMBER][BOARD_SIZE][BOARD_SIZE]; //for?unachieved?feature?pondering
char?*color;????//recent?color
char?*playercolor;
int?win;????//whether?anyone?wins
unsigned?long?long?int?zobrist_list[BOARD_SIZE][BOARD_SIZE][2];???//1?for?black?0?fo
評(píng)論
共有 條評(píng)論