move.h
Go to the documentation of this file.
1 
11 #ifndef EDAX_MOVE_H
12 #define EDAX_MOVE_H
13 
14 #include "const.h"
15 
16 #include <stdio.h>
17 #include <stdbool.h>
18 
20 typedef struct Move {
21  unsigned long long flipped;
22  int x;
23  int score;
24  unsigned int cost;
25  struct Move *next;
26 } Move;
27 
29 typedef struct MoveList {
31  int n_moves;
32 } MoveList;
33 
35 typedef struct Line {
36  char move[GAME_SIZE];
37  int n_moves;
38  int color;
39 } Line;
40 
41 struct Search;
42 struct HashData;
43 struct Board;
44 
45 /* useful constants */
46 extern const Move MOVE_INIT;
47 extern const Move MOVE_PASS;
48 
49 
50 /* function declarations */
51 int symetry(int, const int);
52 
53 void move_print(const int, const int, FILE*);
54 bool move_wipeout(const Move*, const struct Board*);
57 char* move_to_string(const int, const int, char*);
58 
59 void tune_move_evaluate(struct Search*, const char*, const char*);
60 
61 int movelist_get_moves(MoveList*, const struct Board*);
62 void movelist_print(const MoveList*, const int, FILE*);
64 void movelist_evaluate(MoveList*, struct Search*, const struct HashData*, const int, const int);
65 void movelist_evaluate_fast(MoveList*, struct Search*);
68 
69 Move* movelist_exclude(MoveList*, const int);
71 
72 void movelist_sort(MoveList*);
73 void movelist_sort_cost(MoveList*, const struct HashData*);
74 bool movelist_is_empty(const MoveList*);
75 bool movelist_is_single(const MoveList*);
76 
78 #define foreach_move(iter, movelist) \
79  for ((iter) = (movelist)->move->next; (iter); (iter) = (iter)->next)
80 
82 #define foreach_best_move(iter, movelist) \
83  for ((iter) = movelist_best(movelist); (iter); (iter) = move_next_best(iter))
84 
85 void line_init(Line*, const int);
86 void line_push(Line*, const int);
87 void line_pop(Line*);
88 void line_copy(Line*, const Line*, const int);
89 void line_print(const Line*, int, const char*, FILE*);
90 char* line_to_string(const Line *line, int n, const char*, char *string);
91 
93 typedef struct MoveHash {
94  struct MoveArray *array;
95  int size;
96  int mask;
97 } MoveHash;
98 void movehash_init(MoveHash*, int);
100 bool movehash_append(MoveHash*, const struct Board*, const int);
101 
102 #endif
103 
Definition: move.c:661
Move move[MAX_MOVE+2]
Definition: move.h:30
Move * movelist_best(MoveList *)
Return the best move of the list.
Definition: move.c:411
void line_print(const Line *, int, const char *, FILE *)
Print a move sequence.
Definition: move.c:610
int size
Definition: move.h:95
void line_init(Line *, const int)
Initialize a sequence of moves.
Definition: move.c:549
const Move MOVE_PASS
Definition: move.c:26
Move * move_next(Move *)
Return the next move from the list.
Definition: move.c:400
char * line_to_string(const Line *line, int n, const char *, char *string)
Line to string.
Definition: move.c:635
void movehash_delete(MoveHash *)
Free the hash table.
Definition: move.c:730
Move * move_next_best(Move *)
Return the next best move from the list.
Definition: move.c:346
Definition: move.h:93
int color
Definition: move.h:38
Definition: move.h:20
void move_print(const int, const int, FILE *)
Print out a move.
Definition: move.c:110
const Move MOVE_INIT
Definition: move.c:25
struct Line Line
int symetry(int, const int)
Get a symetric square coordinate.
Definition: move.c:47
int mask
Definition: move.h:96
void movelist_restore(MoveList *, Move *)
Definition: board.h:26
unsigned int cost
Definition: move.h:24
struct MoveArray * array
Definition: move.h:94
void line_copy(Line *, const Line *, const int)
Copy part of a sequence to another sequence.
Definition: move.c:591
void movelist_sort_cost(MoveList *, const struct HashData *)
void movelist_evaluate_fast(MoveList *, struct Search *)
unsigned long long flipped
Definition: move.h:21
void movehash_init(MoveHash *, int)
Initialisation of the hash table.
Definition: move.c:715
int x
Definition: move.h:22
Definition: search.h:95
int movelist_get_moves(MoveList *, const struct Board *)
char * move_to_string(const int, const int, char *)
Print out a move.
Definition: move.c:76
void movelist_print(const MoveList *, const int, FILE *)
Print out a movelist.
Definition: move.c:330
struct MoveList MoveList
void movelist_sort(MoveList *)
Sort all moves.
Definition: move.c:505
bool movelist_is_empty(const MoveList *)
Check if the list is empty.
Definition: move.c:537
Definition: move.h:35
int n_moves
Definition: move.h:31
Move * movelist_exclude(MoveList *, const int)
Exclude a move.
Definition: move.c:516
Definition: hash.h:24
struct Move Move
bool movehash_append(MoveHash *, const struct Board *, const int)
bool movelist_is_single(const MoveList *)
void tune_move_evaluate(struct Search *, const char *, const char *)
Move * movelist_first(MoveList *)
Return the first move of the list.
Definition: move.c:422
#define GAME_SIZE
Definition: const.h:25
int n_moves
Definition: move.h:37
struct Move * next
Definition: move.h:25
void movelist_evaluate(MoveList *, struct Search *, const struct HashData *, const int, const int)
Definition: move.h:29
struct MoveHash MoveHash
#define MAX_MOVE
Definition: const.h:18
bool move_wipeout(const Move *, const struct Board *)
void line_push(Line *, const int)
Add a move to the sequence.
Definition: move.c:561
char move[GAME_SIZE]
Definition: move.h:36
Move * movelist_sort_bestmove(MoveList *, const int)
Sort a move as best.
Definition: move.c:468
void line_pop(Line *)
Remove the last move from a sequence.
Definition: move.c:578
int score
Definition: move.h:23