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