My Project
Classes | Macros | Typedefs | Functions | Variables
move.h File Reference
#include "const.h"
#include <stdio.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  Move
 
struct  MoveList
 
struct  Line
 
struct  MoveHash
 

Macros

#define foreach_move(iter, movelist)    for ((iter) = (movelist)->move->next; (iter); (iter) = (iter)->next)
 
#define foreach_best_move(iter, movelist)    for ((iter) = movelist_best(movelist); (iter); (iter) = move_next_best(iter))
 

Typedefs

typedef struct Move Move
 
typedef struct MoveList MoveList
 
typedef struct Line Line
 
typedef struct MoveHash MoveHash
 

Functions

int symetry (int, const int)
 Get a symetric square coordinate. More...
 
void move_print (const int, const int, FILE *)
 Print out a move. More...
 
bool move_wipeout (const Move *, const struct Board *)
 
Movemove_next_best (Move *)
 Return the next best move from the list. More...
 
Movemove_next (Move *)
 Return the next move from the list. More...
 
char * move_to_string (const int, const int, char *)
 Print out a move. More...
 
void tune_move_evaluate (struct Search *, const char *, const char *)
 
int movelist_get_moves (MoveList *, const struct Board *)
 
void movelist_print (const MoveList *, const int, FILE *)
 Print out a movelist. More...
 
Movemovelist_sort_bestmove (MoveList *, const int)
 Sort a move as best. More...
 
void movelist_evaluate (MoveList *, struct Search *, const struct HashData *, const int, const int)
 
void movelist_evaluate_fast (MoveList *, struct Search *)
 
Movemovelist_best (MoveList *)
 Return the best move of the list. More...
 
Movemovelist_first (MoveList *)
 Return the first move of the list. More...
 
Movemovelist_exclude (MoveList *, const int)
 Exclude a move. More...
 
void movelist_restore (MoveList *, Move *)
 
void movelist_sort (MoveList *)
 Sort all moves. More...
 
void movelist_sort_cost (MoveList *, const struct HashData *)
 
bool movelist_is_empty (const MoveList *)
 Check if the list is empty. More...
 
bool movelist_is_single (const MoveList *)
 
void line_init (Line *, const int)
 Initialize a sequence of moves. More...
 
void line_push (Line *, const int)
 Add a move to the sequence. More...
 
void line_pop (Line *)
 Remove the last move from a sequence. More...
 
void line_copy (Line *, const Line *, const int)
 Copy part of a sequence to another sequence. More...
 
void line_print (const Line *, int, const char *, FILE *)
 Print a move sequence. More...
 
char * line_to_string (const Line *line, int n, const char *, char *string)
 Line to string. More...
 
void movehash_init (MoveHash *, int)
 Initialisation of the hash table. More...
 
void movehash_delete (MoveHash *)
 Free the hash table. More...
 
bool movehash_append (MoveHash *, const struct Board *, const int)
 

Variables

const Move MOVE_INIT
 
const Move MOVE_PASS
 

Macro Definition Documentation

◆ foreach_best_move

#define foreach_best_move (   iter,
  movelist 
)     for ((iter) = movelist_best(movelist); (iter); (iter) = move_next_best(iter))

macro to iterate over the movelist from best to worst move

◆ foreach_move

#define foreach_move (   iter,
  movelist 
)     for ((iter) = (movelist)->move->next; (iter); (iter) = (iter)->next)

macro to iterate over the movelist

Typedef Documentation

◆ Line

typedef struct Line Line

(simple) sequence of a legal moves

◆ Move

typedef struct Move Move

move representation

◆ MoveHash

typedef struct MoveHash MoveHash

HashTable of position + move

◆ MoveList

typedef struct MoveList MoveList

(simple) list of a legal moves

Function Documentation

◆ line_copy()

void line_copy ( Line dest,
const Line src,
const int  from 
)

Copy part of a sequence to another sequence.

Parameters
destthe destination move sequence.
srcthe source move sequence.
fromthe point to copy from.

◆ line_init()

void line_init ( Line line,
const int  player 
)

Initialize a sequence of moves.

Parameters
linethe move sequence.
playercolor of the first player of the sequence.

◆ line_pop()

void line_pop ( Line line)

Remove the last move from a sequence.

Parameters
linethe move sequence.

◆ line_print()

void line_print ( const Line line,
int  width,
const char *  separator,
FILE *  f 
)

Print a move sequence.

Parameters
linethe move sequence.
widthwidth of the line to print (in characters).
separatora string to print between moves.
foutput stream.

◆ line_push()

void line_push ( Line line,
const int  x 
)

Add a move to the sequence.

Parameters
linethe move sequence.
xmove coordinate.

◆ line_to_string()

char * line_to_string ( const Line line,
int  n,
const char *  separator,
char *  string 
)

Line to string.

Parameters
linethe move sequence.
nnumber of moves to add.
separatora string to print between moves.
stringoutput string receiving the line.

◆ move_next()

Move * move_next ( Move move)

Return the next move from the list.

Parameters
moveprevious move.
Returns
the next move in the list.

◆ move_next_best()

Move * move_next_best ( Move previous_best)

Return the next best move from the list.

Parameters
previous_bestLast best move.
Returns
the following best move in the list.

◆ move_print()

void move_print ( const int  x,
const int  player,
FILE *  f 
)

Print out a move.

Print the move, using letter case to distinguish player's color, to an output stream.

Parameters
xsquare coordinate to print.
playerplayer color.
foutput stream.

◆ move_to_string()

char * move_to_string ( const int  x,
const int  player,
char *  s 
)

Print out a move.

Print the move, using letter case to distinguish player's color, to an output stream.

Parameters
xSquare coordinate to print.
playerPlayer color.
sOutput string.
Returns
the output string.

◆ move_wipeout()

bool move_wipeout ( const Move ,
const struct Board  
)

◆ movehash_append()

bool movehash_append ( MoveHash ,
const struct Board ,
const int   
)

◆ movehash_delete()

void movehash_delete ( MoveHash hash)

Free the hash table.

Parameters
hashHash table.

◆ movehash_init()

void movehash_init ( MoveHash hash,
int  bitsize 
)

Initialisation of the hash table.

Parameters
hashHash table.
bitsizeHash table size (as log2(size)).

◆ movelist_best()

Move * movelist_best ( MoveList movelist)

Return the best move of the list.

Parameters
movelistThe list of move.
Returns
the best move.

◆ movelist_evaluate()

void movelist_evaluate ( MoveList ,
struct Search ,
const struct HashData ,
const int  ,
const int   
)

◆ movelist_evaluate_fast()

void movelist_evaluate_fast ( MoveList ,
struct Search  
)

◆ movelist_exclude()

Move * movelist_exclude ( MoveList movelist,
const int  move 
)

Exclude a move.

Parameters
movelistList of moves to sort.
moveMove to exclude.

◆ movelist_first()

Move * movelist_first ( MoveList movelist)

Return the first move of the list.

Parameters
movelistThe list of move.
Returns
the first move.

◆ movelist_get_moves()

int movelist_get_moves ( MoveList ,
const struct Board  
)

◆ movelist_is_empty()

bool movelist_is_empty ( const MoveList movelist)

Check if the list is empty.

Parameters
movelistThe list of move.
Returns
true if the list is empty, false otherwise.

◆ movelist_is_single()

bool movelist_is_single ( const MoveList )

◆ movelist_print()

void movelist_print ( const MoveList movelist,
const int  player,
FILE *  f 
)

Print out a movelist.

Print the moves, using letter case to distinguish player's color, to an output stream.

Parameters
movelista list of moves.
playerplayer color.
foutput stream.

◆ movelist_restore()

void movelist_restore ( MoveList ,
Move  
)

◆ movelist_sort()

void movelist_sort ( MoveList movelist)

Sort all moves.

Parameters
movelistList of moves to sort.

◆ movelist_sort_bestmove()

Move * movelist_sort_bestmove ( MoveList movelist,
const int  move 
)

Sort a move as best.

Put the best move at the head of the list.

Parameters
movelistList of moves to sort.
moveBest move to to set first.
Returns
A move, occasionally illegal, whose successor was the original successor of the new best move.

◆ movelist_sort_cost()

void movelist_sort_cost ( MoveList ,
const struct HashData  
)

◆ symetry()

int symetry ( int  x,
const int  sym 
)

Get a symetric square coordinate.

Parameters
xSquare coordinate.
symSymetry.
Returns
Symetric square coordinate.

◆ tune_move_evaluate()

void tune_move_evaluate ( struct Search ,
const char *  ,
const char *   
)

Variable Documentation

◆ MOVE_INIT

const Move MOVE_INIT
extern

◆ MOVE_PASS

const Move MOVE_PASS
extern