Classes | Typedefs | Functions
game.h File Reference
#include "board.h"
#include "move.h"
#include <stdio.h>

Go to the source code of this file.

Classes

struct  Game
 
struct  WthorGame
 
struct  OkoGame
 

Typedefs

typedef struct Game Game
 
typedef struct WthorGame WthorGame
 
typedef struct OkoGame OkoGame
 

Functions

void game_init (Game *)
 Create an empty game. More...
 
void game_copy (Game *, const Game *)
 Game copy. More...
 
bool game_get_board (const Game *, const int, Board *)
 Get the board after 'ply' move. More...
 
bool game_update_board (Board *board, int x)
 update a board. More...
 
bool game_check (Game *)
 Check a game. More...
 
bool game_equals (const Game *, const Game *)
 Test if two games are equal. More...
 
void wthor_to_game (const WthorGame *, Game *)
 convert a Wthor game to a Game. More...
 
void game_to_wthor (const Game *, WthorGame *)
 convert a Game to a Whor game. More...
 
void game_read (Game *, FILE *)
 Read a game from a binary file. More...
 
void game_write (const Game *, FILE *)
 Write a game to a binary file. More...
 
void game_import_text (Game *, FILE *)
 Read a game from a text file. More...
 
void game_import_wthor (Game *, FILE *)
 Read a game from a Wthor file. More...
 
void game_import_ggf (Game *, FILE *)
 Read a game from the Generic Game Format (ggf) file. More...
 
void game_import_sgf (Game *, FILE *)
 Read a game from a sgf file. More...
 
char * parse_ggf (Game *, const char *)
 Parse a ggf game from a string. More...
 
void game_import_pgn (Game *, FILE *)
 Read a game from a pgn file. More...
 
void game_export_text (const Game *, FILE *)
 Write a game to a text file. More...
 
void game_export_ggf (const Game *, FILE *)
 Write a game to the Generic Game Format (ggf) file. More...
 
void game_save_sgf (const Game *, FILE *, const bool)
 Write a game to the Generic Game Format (ggf) file. More...
 
void game_export_sgf (const Game *, FILE *)
 
void game_export_pgn (const Game *, FILE *)
 Write a game to a pgn file. More...
 
void game_export_wthor (const Game *, FILE *)
 Write a game to a Wthor file. More...
 
void game_export_eps (const Game *, FILE *)
 Write a game to an eps file. More...
 
void game_export_svg (const Game *, FILE *)
 
void game_import_oko (Game *, FILE *)
 Read a game from the "allinf.oko" file. More...
 
void game_import_gam (Game *, FILE *)
 
void game_rand (Game *, int, struct Random *)
 Fill a game with some random moves. More...
 
int game_analyze (Game *, struct Search *, const int, const bool)
 Analyze an endgame. More...
 
int game_complete (Game *, struct Search *)
 Terminate an unfinished game. More...
 
void line_to_game (const Board *, const Line *, Game *)
 Build a game from an initial position and a move sequence. More...
 
int game_score (const Game *)
 Compute the final score of the game, for the initial player. More...
 
int move_from_wthor (int)
 Coordinates conversion from wthor to edax. More...
 

Detailed Description

Header file for game management

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Typedef Documentation

◆ Game

typedef struct Game Game

◆ OkoGame

typedef struct OkoGame OkoGame

◆ WthorGame

typedef struct WthorGame WthorGame

Function Documentation

◆ game_analyze()

int game_analyze ( Game game,
Search search,
const int  n_empties,
const bool  apply_correction 
)

Analyze an endgame.

Count how many mistakes occured in the last moves.

Parameters
gameGame to analyze.
searchSearch analyzer.
n_emptiesMove stage to analyze.
apply_correctionFlag to correct or not a game.

◆ game_check()

bool game_check ( Game game)

Check a game.

Parameters
gameGame.
Returns
false if an error occurred.

◆ game_complete()

int game_complete ( Game game,
Search search 
)

Terminate an unfinished game.

Parameters
gameGame to analyze.
searchSearch analyzer.
Returns
number of iterations to terminate the game.

◆ game_copy()

void game_copy ( Game dest,
const Game src 
)

Game copy.

TODO: check if parameter's order is consistant all over the program

Parameters
destDestination Game.
srcSource Game.

◆ game_equals()

bool game_equals ( const Game game_1,
const Game game_2 
)

Test if two games are equal.

Parameters
game_1First Game.
game_2Second Game.

◆ game_export_eps()

void game_export_eps ( const Game game,
FILE *  f 
)

Write a game to an eps file.

Parameters
gameThe input game.
fThe file stream.

◆ game_export_ggf()

void game_export_ggf ( const Game game,
FILE *  f 
)

Write a game to the Generic Game Format (ggf) file.

Parameters
gameThe output game.
fThe file stream.

◆ game_export_pgn()

void game_export_pgn ( const Game game,
FILE *  f 
)

Write a game to a pgn file.

Parameters
gameThe input game.
fThe file stream.

◆ game_export_sgf()

void game_export_sgf ( const Game ,
FILE *   
)

◆ game_export_svg()

void game_export_svg ( const Game ,
FILE *   
)

◆ game_export_text()

void game_export_text ( const Game game,
FILE *  f 
)

Write a game to a text file.

Parameters
gameThe input game.
fThe file stream.

◆ game_export_wthor()

void game_export_wthor ( const Game game,
FILE *  f 
)

Write a game to a Wthor file.

Parameters
gameThe input game.
fThe file stream.

◆ game_get_board()

bool game_get_board ( const Game game,
const int  ply,
Board board 
)

Get the board after 'ply' move.

Parameters
gameGame.
plynumber of move.
boardoutput board.
Returns
false if an error occurred.

◆ game_import_gam()

void game_import_gam ( Game ,
FILE *   
)

◆ game_import_ggf()

void game_import_ggf ( Game game,
FILE *  f 
)

Read a game from the Generic Game Format (ggf) file.

Parameters
gameThe output game.
fThe file stream.

◆ game_import_oko()

void game_import_oko ( Game game,
FILE *  f 
)

Read a game from the "allinf.oko" file.

Parameters
gameThe output game.
fThe file stream.

◆ game_import_pgn()

void game_import_pgn ( Game game,
FILE *  f 
)

Read a game from a pgn file.

Parameters
gameThe output game.
fThe file stream.

◆ game_import_sgf()

void game_import_sgf ( Game game,
FILE *  f 
)

Read a game from a sgf file.

Parameters
gameThe output game.
fThe file stream.

◆ game_import_text()

void game_import_text ( Game game,
FILE *  f 
)

Read a game from a text file.

Parameters
gameThe output game.
fThe file stream.

◆ game_import_wthor()

void game_import_wthor ( Game game,
FILE *  f 
)

Read a game from a Wthor file.

Parameters
gameThe output game.
fThe file stream.

◆ game_init()

void game_init ( Game game)

Create an empty game.

Parameters
gameGame.

◆ game_rand()

void game_rand ( Game game,
int  n_ply,
Random r 
)

Fill a game with some random moves.

Parameters
gameThe output game.
n_plyThe number of random move to generate.
rThe random generator.

◆ game_read()

void game_read ( Game game,
FILE *  f 
)

Read a game from a binary file.

Parameters
gameThe output game.
fThe file stream.

◆ game_save_sgf()

void game_save_sgf ( const Game game,
FILE *  f,
const bool  multiline 
)

Write a game to the Generic Game Format (ggf) file.

Parameters
gameThe output game.
multilineA flag to create a long text or a single line.
fThe file stream.

◆ game_score()

int game_score ( const Game game)

Compute the final score of the game, for the initial player.

Parameters
gameAn input game.
Returns
The score of the game.

◆ game_to_wthor()

void game_to_wthor ( const Game game,
WthorGame thor 
)

convert a Game to a Whor game.

The wthor format is famous as all main event games are recorded into this format.

Parameters
gameAn input game.
thorThe wthor output game.

◆ game_update_board()

bool game_update_board ( Board board,
int  x 
)

update a board.

◆ game_write()

void game_write ( const Game game,
FILE *  f 
)

Write a game to a binary file.

Parameters
gameThe input game.
fThe file stream.

◆ line_to_game()

void line_to_game ( const Board initial_board,
const Line line,
Game game 
)

Build a game from an initial position and a move sequence.

Parameters
initial_boardInitial board.
lineMove sequence.
gameThe output game.

◆ move_from_wthor()

int move_from_wthor ( int  x)

Coordinates conversion from wthor to edax.

Parameters
xwthor coordinate.
Returns
edax coordinate.

◆ parse_ggf()

char* parse_ggf ( Game game,
const char *  string 
)

Parse a ggf game from a string.

Parameters
gameThe output game.
stringAn input string.
Returns
The unprocessed remaining part of the string.

◆ wthor_to_game()

void wthor_to_game ( const WthorGame thor,
Game game 
)

convert a Wthor game to a Game.

The Wthor format is famous as all main event games are recorded into this format. Its name comes from Sylvain Quin's program.

Parameters
thorA single input game.
gameThe output game.