board.h
Go to the documentation of this file.
1 
11 #ifndef EDAX_BOARD_H
12 #define EDAX_BOARD_H
13 
14 #include "const.h"
15 
16 #include <stdio.h>
17 #include <stdbool.h>
18 
19 #ifdef DLL_BUILD
20 #define DLL_API __declspec(dllexport)
21 #else
22 #define DLL_API
23 #endif
24 
26 typedef struct Board {
27  unsigned long long player, opponent;
28 } Board;
29 
30 struct Move;
31 struct Random;
32 
33 /* function declarations */
34 void board_init(Board*);
35 int board_set(Board*, const char*);
36 int board_from_FEN(Board*, const char*);
37 int board_from_obj(Board*, const Board*, const int); // add for libedax by lavox. 2018/1/16
38 int board_compare(const Board*, const Board*);
39 bool board_equal(const Board*, const Board*);
40 void board_symetry(const Board*, const int, Board*);
41 int board_unique(const Board*, Board*);
42 void board_check(const Board*);
43 void board_rand(Board*, int, struct Random*);
44 
45 int board_count_last_flips(const Board*, const int);
46 unsigned long long board_get_move(const Board*, const int, struct Move*);
47 bool board_check_move(const Board*, struct Move*);
49 void board_update(Board*, const struct Move*);
50 void board_restore(Board*, const struct Move*);
51 void board_pass(Board*);
52 unsigned long long board_next(const Board*, const int, Board*);
53 unsigned long long board_pass_next(const Board*, const int, Board*);
54 unsigned long long board_get_hash_code(const Board*);
55 int board_get_square_color(const Board*, const int);
56 bool board_is_occupied(const Board*, const int);
57 void board_print(const Board*, const int, FILE*);
58 char* board_to_string(const Board*, const int, char *);
59 void board_print_FEN(const Board*, const int, FILE*);
60 char* board_to_FEN(const Board*, const int, char*);
61 bool board_is_pass(const Board*);
62 bool board_is_game_over(const Board*);
63 int board_count_empties(const Board *board);
64 
65 int count_last_flip(const int, const unsigned long long);
66 extern unsigned long long (*flip[BOARD_SIZE + 2])(const unsigned long long, const unsigned long long);
67 DLL_API unsigned long long get_moves(const unsigned long long, const unsigned long long);
68 DLL_API bool can_move(const unsigned long long, const unsigned long long);
69 unsigned long long get_moves_6x6(const unsigned long long, const unsigned long long);
70 bool can_move_6x6(const unsigned long long, const unsigned long long);
71 int get_mobility(const unsigned long long, const unsigned long long);
72 int get_weighted_mobility(const unsigned long long, const unsigned long long);
73 int get_potential_mobility(const unsigned long long, const unsigned long long);
74 void edge_stability_init(void);
75 int get_stability(const unsigned long long, const unsigned long long);
76 int get_edge_stability(const unsigned long long, const unsigned long long);
77 int get_corner_stability(const unsigned long long);
78 
79 #endif
80 
struct Board Board
Definition: util.h:87
int board_set(Board *, const char *)
Set a board from a string description.
Definition: board.c:154
int board_compare(const Board *, const Board *)
Compare two board.
Definition: board.c:319
char * board_to_string(const Board *, const int, char *)
convert the to a compact string.
Definition: board.c:1272
unsigned long long board_pass_next(const Board *, const int, Board *)
Compute a board resulting of an opponent move played on a previous board.
Definition: board.c:538
void edge_stability_init(void)
Initialize the edge stability tables.
Definition: board.c:956
int get_corner_stability(const unsigned long long)
Estimate corner stability.
Definition: board.c:1122
void board_pass(Board *)
Passing move.
Definition: board.c:503
#define BOARD_SIZE
Definition: const.h:21
Definition: move.h:20
int get_stability(const unsigned long long, const unsigned long long)
Estimate the stability.
Definition: board.c:1067
int get_potential_mobility(const unsigned long long, const unsigned long long)
Get potential mobility.
Definition: board.c:882
bool board_is_pass(const Board *)
Check if current player should pass.
Definition: board.c:1191
unsigned long long board_get_hash_code(const Board *)
Compute a hash code.
Definition: board.c:1134
int board_unique(const Board *, Board *)
unique board
Definition: board.c:379
Definition: board.h:26
int board_from_FEN(Board *, const char *)
Set a board from a string description.
Definition: board.c:212
char * board_to_FEN(const Board *, const int, char *)
print to FEN description.
Definition: board.c:1312
bool board_is_game_over(const Board *)
Check if the game is over.
Definition: board.c:1203
int board_count_last_flips(const Board *, const int)
void board_check(const Board *)
Check board consistency.
Definition: board.c:291
int board_get_square_color(const Board *, const int)
Get square color.
Definition: board.c:1168
bool can_move_6x6(const unsigned long long, const unsigned long long)
Check if a player can move.
Definition: board.c:814
int count_last_flip(const int, const unsigned long long)
Definition: count_last_flip_bitscan.c:1302
bool board_check_move(const Board *, struct Move *)
Check if a move is legal.
Definition: board.c:452
unsigned long long opponent
Definition: board.h:27
DLL_API bool can_move(const unsigned long long, const unsigned long long)
Check if a player can move.
Definition: board.c:797
unsigned long long get_moves_6x6(const unsigned long long, const unsigned long long)
Get legal moves on a 6x6 board.
Definition: board.c:779
void board_print_FEN(const Board *, const int, FILE *)
print using FEN description.
Definition: board.c:1297
int board_count_empties(const Board *board)
Check if the game is over.
Definition: board.c:1216
void board_init(Board *)
Set a board to the starting position.
Definition: board.c:280
void board_swap_players(Board *)
Swap players.
Definition: board.c:137
int get_weighted_mobility(const unsigned long long, const unsigned long long)
Definition: board.c:838
unsigned long long board_get_move(const Board *, const int, struct Move *)
Compute a move.
Definition: board.c:438
bool board_equal(const Board *, const Board *)
Compare two board for equality.
Definition: board.c:335
int get_mobility(const unsigned long long, const unsigned long long)
Count legal moves.
Definition: board.c:833
bool board_is_occupied(const Board *, const int)
Check if a square is occupied.
Definition: board.c:1180
unsigned long long(* flip[BOARD_SIZE+2])(const unsigned long long, const unsigned long long)
Definition: flip_bitscan.c:1912
void board_symetry(const Board *, const int, Board *)
symetric board
Definition: board.c:347
unsigned long long player
Definition: board.h:27
#define DLL_API
Definition: board.h:22
DLL_API unsigned long long get_moves(const unsigned long long, const unsigned long long)
Get legal moves.
Definition: board.c:621
unsigned long long board_next(const Board *, const int, Board *)
Compute a board resulting of a move played on a previous board.
Definition: board.c:517
void board_print(const Board *, const int, FILE *)
Print out the board.
Definition: board.c:1230
void board_rand(Board *, int, struct Random *)
Get a random board by playing random moves.
Definition: board.c:406
int board_from_obj(Board *, const Board *, const int)
Set a board from a Board object.
Definition: board.c:258
void board_update(Board *, const struct Move *)
void board_restore(Board *, const struct Move *)
int get_edge_stability(const unsigned long long, const unsigned long long)
Estimate the stability of edges.
Definition: board.c:1106