Skip to content

Commit

Permalink
Merge pull request #181 from kobanium/development
Browse files Browse the repository at this point in the history
Fix cgos-genmove_analyze bug
  • Loading branch information
kobanium authored Sep 19, 2024
2 parents 443c858 + 7289b8f commit d2b3dce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/gtp/Gtp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ constexpr char PROGRAM_NAME[] = "Ray";
* @~japanese
* @brief プログラムのバージョン
*/
constexpr char PROGRAM_VERSION[] = "11.1.0";
constexpr char PROGRAM_VERSION[] = "11.2.0";

/**
* @~english
Expand Down
8 changes: 4 additions & 4 deletions include/mcts/AnalysisData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PrincipalVariationData {
* @~japanese
* @brief PVリストの長さ上限
*/
int pv_depth_limit;
unsigned int pv_depth_limit;

/**
* @~english
Expand Down Expand Up @@ -242,7 +242,7 @@ class CgosAnalyzeData {
}
comment = u8"Ray selected pass immediately.";
} else {
win_rate = root.win / root.move_count;
win_rate = static_cast<double>(root.win) / root.move_count;

const child_node_t *children = root.child;

Expand All @@ -254,11 +254,11 @@ class CgosAnalyzeData {
std::sort(pv_data.begin(), pv_data.end(), std::greater<PrincipalVariationData>());
ownership = "";
for (int i = 0; i < pure_board_max; i++) {
const double owner = root.ownership[onboard_pos[i]] / root.move_count;
const double owner = static_cast<double>(root.ownership[onboard_pos[i]]) / root.move_count;
const int owner_index = static_cast<int>(owner * 62);
ownership += owner_char[owner_index];
}
comment = u8"This is the result of Monte-Carlo tree search.";
comment = u8"Ray selected next move based on Monte-Carlo tree search.";
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/gtp/Gtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,9 @@ GTP_cgos_genmove_analyze( void )
if (point != RESIGN) {
PutStone(game, point, color);

CgosAnalyzeData data(GetRootNode(), color);
analyze_data = data.GetJsonData();
}
CgosAnalyzeData data(GetRootNode(), color);
analyze_data = data.GetJsonData();

IntegerToString(point, pos);

Expand Down
2 changes: 2 additions & 0 deletions src/mcts/MCTSNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @~japanese
* @brief MCTSのノードの操作
*/
#include <algorithm>

#include "mcts/MCTSNode.hpp"


Expand Down
11 changes: 4 additions & 7 deletions src/mcts/UctSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void CalculateCriticality( int color );
static void CalculateCriticalityIndex( uct_node_t *node, statistic_t *node_statistic, int color, int *index );

// Ownershipの計算
static void CalculateOwner( int color, int count );
static void CalculateOwner( int color );

// Ownership
static void CalculateOwnerIndex( uct_node_t *node, statistic_t *node_statistc, int color, int *index );
Expand Down Expand Up @@ -995,7 +995,7 @@ ParallelUctSearch( thread_arg_t *arg )
enough_size = CheckRemainingHashSize();
// OwnerとCriticalityを計算する
if (GetPoCount() > interval) {
CalculateOwner(color, GetPoCount());
CalculateOwner(color);
CalculateCriticality(color);
interval += CRITICALITY_INTERVAL;
}
Expand Down Expand Up @@ -1065,7 +1065,7 @@ ParallelUctSearchPondering( thread_arg_t *arg )
enough_size = CheckRemainingHashSize();
// OwnerとCriticalityを計算する
if (GetPoCount() > interval) {
CalculateOwner(color, GetPoCount());
CalculateOwner(color);
CalculateCriticality(color);
interval += CRITICALITY_INTERVAL;
}
Expand Down Expand Up @@ -1382,7 +1382,6 @@ CalculateCriticality( int color )
const double win = static_cast<double>(uct_node[current_root].win) / uct_node[current_root].move_count;
const double lose = 1.0 - win;
double tmp;
const int count = GetPoCount();

for (int i = 0; i < pure_board_max; i++) {
const int pos = onboard_pos[i];
Expand Down Expand Up @@ -1434,14 +1433,12 @@ CalculateOwnerIndex( uct_node_t *node, statistic_t *node_statistic, int color, i
* @~english
* @brief Calculate ownership feature index.
* @param[in] color Player's color.
* @param[in] count Playout count.
* @~japanese
* @brief Ownershipの特徴インデックスの計算
* @param[in] color 手番の色
* @param[in] count プレイアウト回数
*/
static void
CalculateOwner( int color, int count )
CalculateOwner( int color )
{
const double inv_count = (statistic_count.load() > 0) ? 1.0 / statistic_count.load() : 1.0;

Expand Down

0 comments on commit d2b3dce

Please sign in to comment.