LCOV - code coverage report
Current view: top level - Source - tables.cpp (source / functions) Coverage Total Hit
Test: coverage Lines: 100.0 % 56 56
Test Date: 2026-03-02 16:42:41 Functions: 100.0 % 7 7

            Line data    Source code
       1              : #include "tables.hpp"
       2              : 
       3              : #include "logging.hpp"
       4              : #include "searcher.hpp"
       5              : 
       6          275 : void KillerT::initKillers() {
       7          275 :    Logging::LogIt(Logging::logInfo) << "Init killers";
       8          275 :    Logging::LogIt(Logging::logInfo) << "Size of killer table " << sizeof(killers) << "b";
       9        35200 :    for (int k = 0; k < MAX_DEPTH; ++k)
      10       104775 :       for (int i = 0; i < 2; ++i) killers[k][i] = INVALIDMOVE;
      11          275 : }
      12              : 
      13     10373248 : bool KillerT::isKiller(const Move m, const DepthType height) { 
      14     10373248 :    assert(height >= 0);
      15     10373248 :    assert(height < MAX_DEPTH);
      16     10373248 :    const bool isKiller = sameMove(m, killers[height][0]) || sameMove(m, killers[height][1]);
      17              :    //const bool isFormerKiller = height > 1 && sameMove(m, killers[height - 2][0]);// || sameMove(m, killers[height - 2][1]));
      18     10373248 :    return isKiller /*|| isFormerKiller*/;
      19              : }
      20              : 
      21       303123 : void KillerT::update(Move m, DepthType height) {
      22       303123 :    assert(height >= 0);
      23       303123 :    assert(height < MAX_DEPTH);
      24       303123 :    if (!sameMove(killers[height][0], m)) {
      25       224053 :       killers[height][1] = killers[height][0];
      26       224053 :       killers[height][0] = m;
      27              :    }
      28       303123 : }
      29              : 
      30           52 : void HistoryT::initHistory() {
      31           52 :    Logging::LogIt(Logging::logInfo) << "Init history";
      32           52 :    Logging::LogIt(Logging::logInfo) << "Size of history table " << sizeof(history) / 1024 << "Kb";
      33           52 :    Logging::LogIt(Logging::logInfo) << "Size of history piece table " << sizeof(historyP) << "b";
      34           52 :    Logging::LogIt(Logging::logInfo) << "Size of history capture table " << sizeof(historyCap) / 1024 << "Kb";
      35           52 :    Logging::LogIt(Logging::logInfo) << "Size of history counter table " << sizeof(counter_history) / 1024 << "Kb";
      36         3380 :    for (int i = 0; i < NbSquare; ++i)
      37       216320 :       for (int k = 0; k < NbSquare; ++k)
      38       212992 :          history[0][i][k] = history[1][i][k] = 0;
      39              : 
      40          728 :    for (int i = 0; i < NbPiece; ++i)
      41        43940 :       for (int k = 0; k < NbSquare; ++k)
      42        43264 :          historyP[i][k] = 0;
      43              : 
      44          728 :    for (int i = 0; i < NbPiece; ++i)
      45        43940 :       for (int j = 0; j < NbSquare; ++j)
      46       302848 :          for (int k = 0; k < 6; ++k)
      47       259584 :             historyCap[i][j][k] = 0;
      48              : 
      49          728 :    for (int i = 0; i < NbPiece; ++i)
      50        43940 :       for (int j = 0; j < NbSquare; ++j)
      51     36038912 :          for (int k = 0; k < NbPiece * NbSquare; ++k)
      52     35995648 :             counter_history[i][j][k] = -1;
      53           52 : }
      54              : 
      55          275 : void CounterT::initCounter() {
      56          275 :    Logging::LogIt(Logging::logInfo) << "Init counter";
      57          275 :    Logging::LogIt(Logging::logInfo) << "Size of counter table " << sizeof(counter) / 1024 << "Kb";
      58        17875 :    for (int i = 0; i < NbSquare; ++i)
      59      1144000 :       for (int k = 0; k < NbSquare; ++k) counter[i][k] = 0;
      60          275 : }
      61              : 
      62       303123 : void CounterT::update(Move m, const Position& p) {
      63       573290 :    if (isValidMove(p.lastMove)) counter[Move2From(p.lastMove)][correctedMove2ToKingDest(p.lastMove)] = Move2MiniMove(m);
      64       303123 : }
      65              : 
      66       351972 : void updateTables(Searcher& context, const Position& p, DepthType depth, DepthType height, const Move m, TT::Bound bound, CMHPtrArray& cmhPtr) {
      67       351972 :    assert(height >= 0);
      68       351972 :    assert(height < MAX_DEPTH);   
      69       351972 :    if (bound == TT::B_beta) {
      70       303123 :       context.killerT.update(m, height);
      71       303123 :       context.counterT.update(m, p);
      72              :       context.historyT.update<1>(depth, m, p, cmhPtr);
      73              :    }
      74        48849 :    else if (bound == TT::B_alpha)
      75              :       context.historyT.update<-1>(depth, m, p, cmhPtr);
      76       351972 : }
        

Generated by: LCOV version 2.0-1