Skip to content

Commit b346b96

Browse files
authored
Update README.md
1 parent 0ce7de0 commit b346b96

File tree

1 file changed

+126
-22
lines changed

1 file changed

+126
-22
lines changed

README.md

Lines changed: 126 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,68 @@
22
[![codecov](https://codecov.io/gh/CyCTW/Parallel-MCTS/branch/master/graph/badge.svg?token=LPORRSHSZT)](https://codecov.io/gh/CyCTW/Parallel-MCTS)
33

44
# Parallel Monte Carlo Tree Search
5-
This repo contains the implementation of Parallel Monte Carlo Tree Search with C++.
6-
Three parallel method:
7-
- **Leaf parallelization**
8-
- **Root parallelization**
9-
- **Tree parallelization**
5+
This repo implements three methods of Parallel Monte Carlo Tree Search with C++.
6+
7+
**The Three parallel methods:**
8+
- Leaf parallelization
9+
- Root parallelization
10+
- Tree parallelization
1011

1112
Also, we analyze different methods' performance against each other in [Surakarta](https://en.wikipedia.org/wiki/Surakarta_(game)) Game.
12-
If you're interested in details, here is the links of our search:
13+
If you're interested in details, here are the links to our search:
1314
- [Experiment report](https://hackmd.io/2I8fuKY0TY-sRNQU4Dcuog).
1415
- [Slides](https://docs.google.com/presentation/d/11DV9MijsDh2fgR8W5I8kdCT4u630Bibq6ZfMPpffD6U/edit#slide=id.p)
16+
## Features
17+
- CI pipeline (Autobuild, Autotest)
18+
- Code coverage check
19+
## Structure
20+
```
21+
Parallel-MCTS/
22+
├── build
23+
├── CMakeLists.txt
24+
├── CMakeLists.txt.in
25+
├── LICENSE
26+
├── README.md
27+
├── script
28+
│ ├── cov.sh
29+
│ └── record.sh
30+
├── src
31+
│ ├── Agent.h
32+
│ ├── board.h
33+
│ ├── config.h
34+
│ ├── Log.h
35+
│ ├── main.cpp
36+
│ ├── MCTS.h
37+
│ ├── ParallelRoot.h
38+
│ ├── ParallelTree.h
39+
│ ├── Policy.h
40+
│ └── TreeNode.h
41+
└── unittest
42+
└── MCTS_UnitTest.cpp
1543
44+
4 directories, 17 files
45+
```
1646
## Development Environment
1747
- Ubuntu 18.04
1848
- GCC 7.5.0
1949
- CMAKE 3.10
2050
- GoogleTest 1.10.0 (latest)
2151

2252
## Requirement
53+
### Must
2354
- C++ 17
2455
- OpenMP
2556
- CMAKE (3.10)
57+
### optional
58+
- lcov
59+
- gcov
2660

2761
## Build
2862
### Construct build directory (optional, but recommened)
2963
```
3064
mkdir build
3165
```
32-
This step create a `build` directory, which build a clean environment for CMake compiling and building.
66+
This step creates a `build` directory, which builds a clean environment for CMake compiling and building.
3367
### Compile file with CMake
3468
```
3569
cd build
@@ -39,7 +73,7 @@ or
3973
```
4074
cmake .
4175
```
42-
if you don't create `build` directory.
76+
if you don't create the `build` directory.
4377
### Build file
4478
```
4579
cmake --build .
@@ -65,33 +99,35 @@ Usage: mcts [options]
6599
66100
Note: -c (count) & -t (time) options can't be specified simultaneously.
67101
68-
-c --simCount <simulationCount> Set simulation count per step
69-
-t --simTime <simulationTime (second)> Set simulation time per step
70-
-T --threadNum <threadNum> Set number of thread num
102+
-c --simCount <simulationCount> Set simulation count per step. default: 1000
103+
-t --simTime <simulationTime (second)> Set simulation time per step. default: -1
104+
-T --threadNum <threadNum> Set number of thread num. default: 4
71105
-p --policy <blackAndWhitePolicy> Set Player's policy
72-
<blackPolicy> <whitePolicy> ( choice: Serial, Leaf, Root, Tree. default: Tree Serial)
106+
<blackPolicy> <whitePolicy> (options: Serial, Leaf, Root, Tree) default: Tree Serial)
107+
73108
-m --method <blackAndWhiteMethod> Set Player's arallel methods
74-
<blackMethod> <whiteMethod> ( choice: openmp, pthread. default: openmp )
75-
-? --help Edit config.h to set parameter
109+
<blackMethod> <whiteMethod> (options: openmp, pthread) default: openmp)
110+
111+
-? --help Help message.
76112
```
77113

78-
### Some Examples:
79-
- Serial version (Black) v.s. Serial version (White) with simulation count $1000$
114+
### Some quick examples:
115+
- Serial version (Black) v.s. Serial version (White) with simulation count 1000
80116
```
81117
./mcts -c 1000 -p Serial
82118
```
83-
- ParallelTree version (Black) v.s. Serial version (White) with simulation time $2s$
119+
- ParallelTree version (Black) v.s. Serial version (White) with simulation time 2s
84120
```
85121
./mcts -t 2 -p Tree Serial
86122
```
87123
*Note: we can't set Count and Time simultaneously, choose only one option.*
88124
89-
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with $4$ thread, both use `openmp` implementation.
125+
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with 4 thread, both use `openmp` implementation.
90126
```
91127
./mcts -T 4 -p Root Tree -m openmp
92128
```
93129
94-
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with $4$ thread. Use `openmp` (Black) and `pthread` (White) implementation.
130+
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with 4 thread. Use `openmp` (Black) and `pthread` (White) implementation.
95131
```
96132
./mcts -T 4 -p Root Leaf -m openmp pthread
97133
```
@@ -107,9 +143,77 @@ ctest
107143
Both command will run the same unittest script stored in `<ProjectRoot>/unittest/MCTS_UnitTest.cpp`
108144
109145
*Note:*
110-
*The first command run test script using Googletest's origin format.*
111-
*The second command run the same test script, but from CMake.*
146+
*The first command runs the test script using Googletest's origin format.*
147+
148+
*The second command runs the same test script, but from CMake.*
112149
### Explanation
113-
Mainly, the test script check the Monte Carlo Tree Search's simulation count and simulation time works correctly.
150+
Mainly, the test script checks the Monte Carlo Tree Search's simulation count and simulation time works correctly.
151+
152+
## CodeCoverage Report
153+
If you want to see the code coverage report, you should recompile the project with `-DCOVERAGE=ON`
154+
*Note: default option is `-DCOVERAGE=OFF` because this option will slow down the whole program.*
155+
156+
First return to build directory.
157+
```
158+
cd <ProjectRoot>/build
159+
```
160+
Then, recompile project with flag `-DCOVERAGE=OFF`
161+
```
162+
cmake -DCOVERAGE=ON ..
163+
```
164+
Rebuild the project
165+
```
166+
cmake --build .
167+
```
168+
Last, move to `script` folder and execute the `cov.sh` script.
169+
```
170+
cd <ProjectRoot>/script
171+
./cov.sh
172+
```
173+
*Note: you should install `lcov` and `gcov` before execute the script.*
174+
175+
If everything works fine, the script will open a html file, which contains the code coverage report.
176+
## Experiment record
177+
If you want to run multiple games on different policys, and record the result for further analysis, you can check our `record.sh`
114178
179+
You can move to `script` directory to check the `record.sh` file.
180+
```
181+
cd <ProjectRoot>/script
182+
```
183+
### usage
184+
```
185+
Usage: ./record.sh [options]
115186

187+
Note: -c (count) & -t (time) options can't be specified simultaneously.
188+
189+
-c --simCount <simulationCount> Set simulation count per step. default: 1000
190+
-t --simTime <simulationTime (second)> Set simulation time per step. default: -1
191+
-T --threadNum <threadNum> Set number of thread num. default: 4
192+
-p --policy <blackAndWhitePolicy> Set Player's policy
193+
<blackPolicy> <whitePolicy> (options: Serial, Leaf, Root, Tree) default: Tree Serial)
194+
195+
-m --method <blackAndWhiteMethod> Set Player's arallel methods
196+
<blackMethod> <whiteMethod> (options: openmp, pthread) default: openmp)
197+
198+
```
199+
200+
### Some quick examples:
201+
- Serial version (Black) v.s. Serial version (White) with simulation count 1000
202+
```
203+
./record.sh -c 1000 -p Serial
204+
```
205+
- ParallelTree version (Black) v.s. Serial version (White) with simulation time 2s
206+
```
207+
./record.sh -t 2 -p Tree Serial
208+
```
209+
*Note: we can't set Count and Time simultaneously, choose only one option.*
210+
211+
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with 4 thread, both use `openmp` implementation.
212+
```
213+
./record.sh -T 4 -p Root Tree -m openmp
214+
```
215+
216+
- ParallelRoot version (Black) v.s. ParallelLeaf (White) with 4 thread. Use `openmp` (Black) and `pthread` (White) implementation.
217+
```
218+
./record.sh -T 4 -p Root Leaf -m openmp pthread
219+
```

0 commit comments

Comments
 (0)