Skip to content

Commit

Permalink
design doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zchen0211 committed May 7, 2018
1 parent 113aba7 commit 1ac031a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
8 changes: 4 additions & 4 deletions design_doc/go_game.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Go Game Rule part.

## 0. Basic info
## Basic info
- in src_cpp/elfgames/go/base/board.h
- Define basic types and coordinates operation:
```cpp
Expand Down Expand Up @@ -42,7 +42,7 @@ FindAllCandidateMoves();
float getTrompTaylorScore();
```
## 1. Go State
## Go State
- A class with all the above functions integrated;
- in src_cpp/elfgames/go/base/go_state.h
```cpp
Expand All @@ -61,7 +61,7 @@ private:
};
```

## 2. Go State Ext
## Go State Ext
- A class wrapped on GoState to support online behavior;
- in src_cpp/elfgames/go/go_state_ext.h
```cpp
Expand All @@ -85,7 +85,7 @@ class GoStateExt {
```
- class GoStateExtOffline
```cpp
class GoStateExtOffline {}
class GoStateExtOffline {
fromRecord();
switchRandomMove(rng);
generateD4Code(rng);
Expand Down
10 changes: 5 additions & 5 deletions design_doc/mcts.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# MCTS AI C++ Interface
# MCTS in ELF OpenGo

- MCTS is generally implemented in C++ with templates.
- Three important concepts: **Actor**, **Action**, **State**.
- General implementations available in the directory src_cpp/elf/ai/tree_search;
- Go-specific available in src_cpp/elfgames/go/mcts/
- Two modes are supported: a multi-threading mode for training (used in selfplay games), and a pseudo-multi-threading batch mode for online games (e.g., gtp).

## 1. ``Actor``
## Actor
- class MCTSActor, a go specific implementation in src_cpp/elfgames/go/mcts/mcts.h
- Important member function **evaluate** pre-evaluate, get feature and call neural network if necessary, post-process and save in resp;
```cpp
Expand All @@ -31,7 +31,7 @@ private:
post_nn(); // pi2response
```

## 2. MCTS Go AI
## MCTS Go AI
- class **MCTSGoAI**, derived from class **MCTSAI_T<MCTSActor>**. In the class we add following members:
```cpp
class MCTSGoAI : public MCTSAI_T<MCTSActor> {
Expand Down Expand Up @@ -82,7 +82,7 @@ private:
};
```
## 2. ``Tree Search Details``
## Tree Search Details
- class **TreeSearchSingleThread** in folder src_cpp/elf/ai/tree_search/tree_search.h is for training multi-threading execution.
```cpp
template <typename State, typename Action>
Expand Down Expand Up @@ -164,7 +164,7 @@ private:
};
```
## 3. Tree and Nodes
## Tree and Nodes
- Base class **NodeBase**
```cpp
template<State>
Expand Down
3 changes: 2 additions & 1 deletion design_doc/model_interface.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Model Interface in ELF

## Model Interface
- class ModelInterface is a python class saving network models
- class ModelInterface is a python class saving network models.
- Its member `models` is a k-v store to call a CNN model by name.
```python
class ModelInterface(object):
def __init__(self, option_map):
Expand Down
25 changes: 13 additions & 12 deletions design_doc/options.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# ELF Option Parser and Interface

## 0. Design of Option
1. Basically in the folder src_cpp/elf/options/ and src_py/elf/options/;
2. Important classes like **game**, **model**, **trainer**, **evaluator**, **sampler** and so forth;
Since ELF Go project has a lot of options, we have a separate folding to manage and implement options in both C++ and python.

## 1. Option Spec Class
1. All arguments from command line are parsed by argparser in py_option_spec.py
2. class **PyOptionSpec** does the parsing;
3. Inheritted from class **OptionSpec** in C++;
3. After doing the parsing, **parse()** will convert the parsed arguments to a Option Map class.
## Design of Option
- Basically in the folder src_cpp/elf/options/ and src_py/elf/options/;
- Important classes like **game**, **model**, **trainer**, **evaluator**, **sampler** and so forth;

## Option Spec Class (Python)
- All arguments from command line are parsed by argparser in py_option_spec.py
- class **PyOptionSpec** does the parsing;
- Inheritted from class **OptionSpec** in C++;
- After doing the parsing, **parse()** will convert the parsed arguments to a Option Map class.

## 2. Option Map Class
1. A class to handle Argument by Json shared info between python and C++;
2. class **PyOptionMap** receives a **PyOptionSpec** class and saves as a member;
3. Inherited from class **OptionMap** in C++;
## Option Map Class (Python)
- A class to handle Argument by Json shared info between python and C++;
- class **PyOptionMap** receives a **PyOptionSpec** class and saves as a member;
- Inherited from class **OptionMap** in C++;

## 3. Detailed Design
- class OptionSpec (C++)
Expand Down
2 changes: 1 addition & 1 deletion design_doc/sampler.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sampler in ELF

Python class in src_py/rlpytorch/sampler/ folder.
Python class in src_py/rlpytorch/sampler/ folder. It is a little out-of-date and not realy used in the Go project.

## Class Sampler
- Used to sample an action from policy.
Expand Down
2 changes: 1 addition & 1 deletion design_doc/trainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Evaluator(object):
```

## Trainer
- An extra rl_method added to the Evaluator, has a member as evaluator
- Trainer is also a pure python class wrapped on evaluator.
```python
class Trainer(object):
def __init__(self, option_map, ...):
Expand Down

0 comments on commit 1ac031a

Please sign in to comment.