<commit_before>/* TTElement.hpp
 *
 * <NAME>
 */

#ifndef SUNFISH_TT_TTSLOT_HPP__
#define SUNFISH_TT_TTSLOT_HPP__

#include "search/eval/Score.hpp"
#include "core/move/Move.hpp"
#include "core/position/Zobrist.hpp"
#include <cstdint>
#include <cassert>

// 1st quad word
#define TT_MATE_MASK   0x0000000000000001LLU
#define TT_HASH_MASK   0xfffffffffffffffeLLU

#define TT_MATE_WIDTH   1
#define TT_HASH_WIDTH  63

#define TT_MATE_SHIFT   0

static_assert(TT_MATE_WIDTH
            + TT_HASH_WIDTH <= 64, "invalid data size");
static_assert(TT_MATE_MASK == (((1LLU << TT_MATE_WIDTH) - 1LLU) << TT_MATE_SHIFT), "invalid status");
static_assert(TT_HASH_MASK == (~((1LLU << (64 - TT_HASH_WIDTH)) - 1)), "invalid status");

// 2nd quad word
#define TT_MOVE_MASK  0x000000000000ffffLLU
#define TT_SCORE_MASK 0x00000000ffff0000LLU
#define TT_STYPE_MASK 0x0000000300000000LLU
#define TT_DEPTH_MASK 0x00000ffc00000000LLU
#define TT_CSUM_MASK  0xffff000000000000LLU

#define TT_MOVE_WIDTH  16
#define TT_SCORE_WIDTH 16
#define TT_STYPE_WIDTH  2
#define TT_DEPTH_WIDTH 10
#define TT_CSUM_WIDTH  16

#define TT_MOVE_SHIFT  0
#define TT_SCORE_SHIFT (TT_MOVE_SHIFT + TT_MOVE_WIDTH)
#define TT_STYPE_SHIFT (TT_SCORE_SHIFT + TT_SCORE_WIDTH)
#define TT_DEPTH_SHIFT (TT_STYPE_SHIFT + TT_STYPE_WIDTH)

static_assert(TT_MOVE_WIDTH
            + TT_SCORE_WIDTH
            + TT_STYPE_WIDTH
            + TT_DEPTH_WIDTH
            + TT_CSUM_WIDTH <= 64, "invalid data size");
static_assert(TT_MOVE_MASK  == (((1LLU << TT_MOVE_WIDTH) - 1) << TT_MOVE_SHIFT), "invalid status");
static_assert(TT_SCORE_MASK == (((1LLU << TT_SCORE_WIDTH) - 1) << TT_SCORE_SHIFT), "invalid status");
static_assert(TT_STYPE_MASK == (((1LLU << TT_STYPE_WIDTH) - 1) << TT_STYPE_SHIFT), "invalid status");
static_assert(TT_DEPTH_MASK == (((1LLU << TT_DEPTH_WIDTH) - 1) << TT_DEPTH_SHIFT), "invalid status");<commit_msg>Fix TT<commit_after>/* TTElement.hpp
 *
 * <NAME>
 */

#ifndef SUNFISH_TT_TTSLOT_HPP__
#define SUNFISH_TT_TTSLOT_HPP__

#include "search/eval/Score.hpp"
#include "core/move/Move.hpp"
#include "core/position/Zobrist.hpp"
#include <cstdint>
#include <cassert>

// 1st quad word
#define TT_MATE_MASK   0x8000000000000000LLU
#define TT_HASH_MASK   0x7fffffffffffffffLLU

#define TT_HASH_WIDTH  63
#define TT_MATE_WIDTH   1

#define TT_MATE_SHIFT  63

static_assert(TT_MATE_WIDTH
            + TT_HASH_WIDTH <= 64, "invalid data size");
static_assert(TT_MATE_MASK == (((1LLU << TT_MATE_WIDTH) - 1LLU) << TT_MATE_SHIFT), "invalid status");
static_assert(TT_HASH_MASK == ~TT_MATE_MASK, "invalid status");

// 2nd quad word
#define TT_MOVE_MASK  0x000000000000ffffLLU
#define TT_SCORE_MASK 0x00000000ffff0000LLU
#define TT_STYPE_MASK 0x0000000300000000LLU
#define TT_DEPTH_MASK 0x00000ffc00000000LLU
#define TT_CSUM_MASK  0xffff000000000000LLU

#define TT_MOVE_WIDTH  16
#define TT_SCORE_WIDTH 16
#define TT_STYPE_WIDTH  2
#define TT_DEPTH_WIDTH 10
#define TT_CSUM_WIDTH  16

#define TT_MOVE_SHIFT  0
#define TT_SCORE_SHIFT (TT_MOVE_SHIFT + TT_MOVE_WIDTH)
#define TT_STYPE_SHIFT (TT_SCORE_SHIFT + TT_SCORE_WIDTH)
#define TT_DEPTH_SHIFT (TT_STYPE_SHIFT + TT_STYPE_WIDTH)

static_assert(TT_MOVE_WIDTH
            + TT_SCORE_WIDTH
            + TT_STYPE_WIDTH
            + TT_DEPTH_WIDTH
            + TT_CSUM_WIDTH <= 64, "invalid data size");
static_assert(TT_MOVE_MASK  == (((1LLU << TT_MOVE_WIDTH) - 1) << TT_MOVE_SHIFT), "invalid status");
static_assert(TT_SCORE_MASK == (((1LLU << TT_SCORE_WIDTH) - 1) << TT_SCORE_SHIFT), "invalid status");
static_assert(TT_STYPE_MASK == (((1LLU << TT_STYPE_WIDTH) - 1) << TT_STYPE_SHIFT), "invalid status");
static_assert(TT_DEPTH_MASK == (((1LLU << TT_DEPTH_WIDTH) - 1) << TT_DEPTH_SHIFT), "invalid status");
{'fraction_non_alphanumeric': 0.10826824670078104, 'fraction_numerical': 0.06517640721788312, 'mean_word_length': 5.481675392670157, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 16, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5080841', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1448, 'n_words': 277}