extern Movestruct *MoveStack;
extern SBoard *BoardStack;

extern int SearchDepth, flipboard , thinking, bAcceptDraw;
extern unsigned char PlayerCOLOR;
extern float Thinktime, fPanicTime;
extern int  stopthinking, g_SearchColor;
extern int g_nNoChange, g_RecapSquare;
extern int DRAWSCORE;

extern int PV	 [MAXDEPTH+3][MAXDEPTH+3];
extern unsigned int WPHashSq [128];
extern unsigned int BPHashSq [128];

// Structures

struct HashEntry
    {
	 unsigned int checksum;
     short eval;
     unsigned short bestmove;
     unsigned char age;
     signed char mate, depth, failtype;
    };

// Function Definitions
int CompMove (SBoard& Board, int nFlags, int MaxAhead);
short ABSearch(int color, int ahead, int depth, short alpha, short beta,  int &bestmove, int bAfterNull);

int GetTTEntry ( SBoard &Board, HashEntry &TEntry);
void SetHashMB ( unsigned int nMegs );
void Clear_Hash (void);
void Create_HashFunction ( );
unsigned int Hash_Board2 ( const SBoard &Board);
unsigned int Hash_Board ( const SBoard &Board);
unsigned int Pawn_HashBoard (const SBoard &Board); // In Evaluate.cpp

void GetPVString ( char *buffer, int format );
int CheckGameOver ( SBoard &Board, int bPopUps, int &GameResult );
int IsMate ( SBoard &Board, char Color);
int FindMateThreat ( SBoard &Board, char Color, int ahead);
void SetHashSizeBits ( int nBits );
void InitSearchGlobals ( SBoard &Board );
void SetThinkTime (float nCompTm, int nMoves, int nSecs );
void UpdateDisplayInfo ( int i, int MMove, int Max, int bestmove );
void ExtendThinkTime ( );
//void SetPanicTime ( float fCompTm);
void inline SetPanicTime ( float fCompTm)
	{
	if ((Thinktime+1) > fCompTm) Thinktime = fCompTm*0.4f;
	if (Thinktime < .01f ) Thinktime = .01f;
	fPanicTime = Thinktime * 3.1f;
	while ((Thinktime+fPanicTime) + 6 > fCompTm && fPanicTime > 0.5f)  fPanicTime *=.5f;
	if (fPanicTime <= 0.5f) fPanicTime = 0.0f;
	}

// Draw
//void AddRepBoard ( const unsigned int hashV, const SBoard &Board );
void AddRepBoard ( const SBoard &Board);
int DrawByRepetition ( unsigned int hashV, const SBoard &Board);
int DrawByRepetition ( SBoard &Board);

// From Winboard.cpp
void wbSendMove( );
void wbSendThinking(int ply, int eval, unsigned long tm, unsigned int nodes, int bPV, int bFailHigh, int bFinishedDepth);
void wbTestSendResult ( SBoard &Board );
void wbSendResult(char *sResult, char *sWhy);
void wbSendThinking2( int bFinishedDepth );
void UCISendThinking( int bFinishedDepth );
int GetPVMoveString (char* buffer, int nMove, int format);
int ResignOrDraw ( int nEval, int color );
