/*
    Copyright 2015 Harm Jetten

    This file is part of Moby Dam.

    Moby Dam is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moby Dam is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moby Dam.  If not, see <http://www.gnu.org/licenses/>.
*/

/* mix64 -- Source: lookup8.c, by Bob Jenkins, January 4 1997, Public Domain. */
#define mix64(a,b,c) \
{ \
  a -= b; a -= c; a ^= (c>>43); \
  b -= c; b -= a; b ^= (a<<9); \
  c -= a; c -= b; c ^= (b>>8); \
  a -= b; a -= c; a ^= (c>>38); \
  b -= c; b -= a; b ^= (a<<23); \
  c -= a; c -= b; c ^= (b>>5); \
  a -= b; a -= c; a ^= (c>>35); \
  b -= c; b -= a; b ^= (a<<49); \
  c -= a; c -= b; c ^= (b>>11); \
  a -= b; a -= c; a ^= (c>>12); \
  b -= c; b -= a; b ^= (a<<18); \
  c -= a; c -= b; c ^= (b>>22); \
}

typedef struct {
    u64 ttsig;
    union {
        struct {
             u8 alphabound: 1;
             u8 betabound : 1;
             u8 depth;
            u16 bestmove;
            s32 score;
        };
        u64 data;
    };
} ttentry;

extern void flush_tt(void);
extern void wipe_tt(void);
extern bool init_tt(u64 ttentries);
extern bool probe_tt(bitboard *bb, int ply, int depth, s32 alpha, s32 beta, s32 *scoreptr, int *bestptr);
extern void store_tt(bitboard *bb, int ply, int depth, s32 alpha, s32 beta, s32 score, int bestmove);
extern int sprint_pv(char *str, bitboard *ply0mvptr);
