グローバル詰みテーブルのアクセスタイミングを変更
元々はこんな感じで、内部ノードの探索開始時にグローバル詰みテーブルのデータを読み込んでました。
double Searcher::searchNegaMax( Position *const position, ... ) { // グローバル詰みテーブル読み込み const int mateInfo = globalMateTable->get( position ); if( mateInfo != 0 ) { // 詰みを検出した場合の処理 return ...; }// if(...) for( /* 全ての手 */ ) { // 手を指したりとか色々 const double score = -this->searchNegaMax( position, ... ); // 手を戻したりとか色々 }// for(...) // 詰みを発見したらグローバル詰みテーブルに登録 if( /* 詰みを発見した */ ) globalMateTable->set( position, ... ); return ...; }// searchNegaMax(...)
ただ、これだとテーブルのヒット率が低いので、こんな感じで再帰的に探索する直前に何度もテーブルをチェックしに行く様に変更。
double Searcher::searchNegaMax( Position *const position, ... ) { for( /* 全ての手 */ ) { // グローバル詰みテーブル読み込み const int mateInfo = globalMateTable->get( position ); if( mateInfo != 0 ) { // 詰みを検出した場合の処理 return ...; }// if(...) // 手を指したりとか色々 const double score = -this->searchNegaMax( position, ... ); // 手を戻したりとか色々 }// for(...) // 詰みを発見したらグローバル詰みテーブルに登録 if( /* 詰みを発見した */ ) globalMateTable->set( position, ... ); return ...; }// searchNegaMax(...)
で、多少はヒット率上がって強さに貢献してくれないかなぁ、と。
現在は修正前のコードで連続対局中なので、この修正の効果が分かるのは明後日の夜になりそうです。