Skip to content

Commit

Permalink
fix: some adjustments. 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Joker2770 committed Apr 27, 2023
1 parent 582585e commit 98bdb17
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -Wl,-rpath=./:./lib")
set(ONNXRUNTIME_ROOTDIR "/mnt/d/Linker/onnxruntime-linux-x64-1.11.1")
else()
set(ONNXRUNTIME_ROOTDIR "D:/Linker/onnxruntime-win-x86-1.11.1")
set(ONNXRUNTIME_ROOTDIR "D:/Linker/onnxruntime-win-x64-gpu-1.11.1")
endif()

# tensorrt_provider_factory.h contains old APIs of the tensorrt execution provider
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ cmake .. # (or "cmake -A x64 ..")
cmake --build . --config Release # (or open .sln file through visual Studio 19 and generate for win10)
```

add `-DUSE_CUDA=ON` to enable gpu.

## Train (Linux)

```shell
Expand Down
3 changes: 0 additions & 3 deletions src/mcts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,6 @@ void MCTS::simulate(std::shared_ptr<Gomoku> game)
}
}

// std::cout << "value = " << value << std::endl;
// std::cout << "action_priors = " << action_priors << std::endl;

double sum = 0;
for (unsigned int i = 0; i < action_priors.size(); i++)
{
Expand Down
7 changes: 3 additions & 4 deletions src/onnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ NeuralNetwork::NeuralNetwork(const std::string model_path, const unsigned int ba

session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);

//#define USE_CUDA
#ifdef USE_CUDA
void enable_cuda(OrtSessionOptions * session_options)
{
ORT_ABORT_ON_ERROR(OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 0));
}
OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 0);
//std::cout << "DEBUG ......Enable CUDA......" << std::endl;
#endif

#ifdef _WIN32
Expand Down
6 changes: 3 additions & 3 deletions src/pbrain-Z2I/pbrain-Z2I.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ int main(int argc, char *argv[])
module = new NeuralNetwork(s_model_path, NUM_MCT_SIMS);

unsigned int u_timeout_turn = 30000;
double per_sims = (double)(u_timeout_turn)/(double)(4*60000);
double per_sims = (double)(u_timeout_turn)/(double)(4*30000);
cout << "DEBUG per_sims: " << per_sims << endl;

MCTS *m;
m = new MCTS(module, NUM_MCT_THREADS, C_PUCT, (unsigned int)(NUM_MCT_SIMS * NUM_MCT_THREADS * per_sims), C_VIRTUAL_LOSS, BORAD_SIZE * BORAD_SIZE);
m = new MCTS(module, NUM_MCT_THREADS, C_PUCT, (unsigned int)(NUM_MCT_SIMS * log(NUM_MCT_THREADS) * per_sims), C_VIRTUAL_LOSS, BORAD_SIZE * BORAD_SIZE);

string command;
unsigned int size;
Expand Down Expand Up @@ -485,7 +485,7 @@ int main(int argc, char *argv[])
delete m;
m = nullptr;
}
m = new MCTS(module, NUM_MCT_THREADS, C_PUCT, (unsigned int)(NUM_MCT_SIMS * NUM_MCT_THREADS * per_sims * (value * 0.1 / u_timeout_turn) + 1), C_VIRTUAL_LOSS, BORAD_SIZE * BORAD_SIZE);
m = new MCTS(module, NUM_MCT_THREADS, C_PUCT, (unsigned int)(NUM_MCT_SIMS * log(NUM_MCT_THREADS) * per_sims * (value * 0.1 / u_timeout_turn) + 1), C_VIRTUAL_LOSS, BORAD_SIZE * BORAD_SIZE);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ void SelfPlay::play(unsigned int saved_id)

while (game_state.first == 0)
{
// g->render();
double temp = step < EXPLORE_STEP ? 1 : 0;
// cout << "game id: " << saved_id << endl;
double temp = step < EXPLORE_STEP ? 1.0 : 1e-3;
auto action_probs = mcts->get_action_probs(g.get(), temp);
// auto action_probs = m->get_action_probs(g.get(), 1);
// int best_action = m->get_best_action_from_prob(action_probs);

board_type board = g->get_board();
for (int i = 0; i < BORAD_SIZE * BORAD_SIZE; i++)
{
Expand Down Expand Up @@ -115,6 +114,7 @@ void SelfPlay::play(unsigned int saved_id)
mcts->update_with_move(res);
g->execute_move(res);
game_state = g->get_game_status();
g->render();
step++;
}
cout << "Self play: total step num = " << step << " winner = " << game_state.second << endl;
Expand Down

0 comments on commit 98bdb17

Please sign in to comment.