Skip to content

Commit

Permalink
reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-shawn committed Jan 12, 2025
1 parent 2c2621a commit 4f6ff39
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,27 @@ class StatsEntry {
};

template<typename T, std::size_t Size, std::size_t... Sizes>
struct MultiArrayHelper;
class MultiArray;

namespace Detail {

template<typename T, std::size_t Size, std::size_t... Sizes>
struct MultiArrayHelper {
using child_type = MultiArray<T, Sizes...>;
};

template<typename T, std::size_t Size>
struct MultiArrayHelper<T, Size> {
using child_type = T;
};

}

// MultiArray is a generic N-dimensional array used by various statistics.
// The template parameters (Size and Sizes) encode the dimensions of the array.
template<typename T, std::size_t Size, std::size_t... Sizes>
class MultiArray {
using child_type = typename MultiArrayHelper<T, Size, Sizes...>::child_type;
using child_type = typename Detail::MultiArrayHelper<T, Size, Sizes...>::child_type;
using array_type = std::array<child_type, Size>;
array_type data;

Expand Down Expand Up @@ -132,16 +146,6 @@ class MultiArray {
}
};

template<typename T, std::size_t Size, std::size_t... Sizes>
struct MultiArrayHelper {
using child_type = MultiArray<T, Sizes...>;
};

template<typename T, std::size_t Size>
struct MultiArrayHelper<T, Size> {
using child_type = T;
};

enum StatsType {
NoCaptures,
Captures
Expand Down Expand Up @@ -191,6 +195,8 @@ enum CorrHistType {

using CorrHistEntry = StatsEntry<std::int16_t, CORRECTION_HISTORY_LIMIT>;

namespace Detail {

template<CorrHistType _>
struct CorrHistTypedef {
using type = MultiArray<CorrHistEntry, COLOR_NB, CORRECTION_HISTORY_SIZE>;
Expand All @@ -206,8 +212,10 @@ struct CorrHistTypedef<Continuation> {
using type = MultiArray<CorrHistTypedef<PieceTo>::type, PIECE_NB, SQUARE_NB>;
};

}

template<CorrHistType T>
using CorrectionHistory = typename CorrHistTypedef<T>::type;
using CorrectionHistory = typename Detail::CorrHistTypedef<T>::type;

} // namespace Stockfish

Expand Down

0 comments on commit 4f6ff39

Please sign in to comment.