#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED

#include "position.h"

#define GM_PLY_MAX 1024

// the game data type
typedef struct {
    POSITION pos[GM_PLY_MAX];
    int root;
} GAME;

// clear the game and reset the first position
void gm_reset(GAME* gm, const POSITION* pos);

// make a move at a given ply (change the root if negative)
int gm_make_mv(GAME* gm, int ply, MOVE mv);
void gm_make_null_mv(GAME* gm, int ply);

// get a pointer to the position at a given ply
POSITION* gm_get_ply(const GAME* gm, int ply);

// repetition detection
int is_repeat(const GAME* gm, int ply);

// FEN constants
#define FEN_START "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
#define FEN_MAX 128

// input/output in UCI format
int gm_scan_uci(char* uci, GAME* gm, int c960);

// test the functions above
int gm_test();

#endif // GAME_H_INCLUDED
