From 1ac031a3916b811856df86eadaf110f11dbe45be Mon Sep 17 00:00:00 2001 From: zhuoyuan Date: Mon, 7 May 2018 15:19:19 -0700 Subject: [PATCH] design doc --- design_doc/go_game.md | 8 ++++---- design_doc/mcts.md | 10 +++++----- design_doc/model_interface.md | 3 ++- design_doc/options.md | 25 +++++++++++++------------ design_doc/sampler.md | 2 +- design_doc/trainer.md | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/design_doc/go_game.md b/design_doc/go_game.md index 21a4d12..216f458 100644 --- a/design_doc/go_game.md +++ b/design_doc/go_game.md @@ -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 @@ -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 @@ -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 @@ -85,7 +85,7 @@ class GoStateExt { ``` - class GoStateExtOffline ```cpp -class GoStateExtOffline {} +class GoStateExtOffline { fromRecord(); switchRandomMove(rng); generateD4Code(rng); diff --git a/design_doc/mcts.md b/design_doc/mcts.md index ffa6def..185129c 100644 --- a/design_doc/mcts.md +++ b/design_doc/mcts.md @@ -1,4 +1,4 @@ -# MCTS AI C++ Interface +# MCTS in ELF OpenGo - MCTS is generally implemented in C++ with templates. - Three important concepts: **Actor**, **Action**, **State**. @@ -6,7 +6,7 @@ - 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 @@ -31,7 +31,7 @@ private: post_nn(); // pi2response ``` -## 2. MCTS Go AI +## MCTS Go AI - class **MCTSGoAI**, derived from class **MCTSAI_T**. In the class we add following members: ```cpp class MCTSGoAI : public MCTSAI_T { @@ -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 @@ -164,7 +164,7 @@ private: }; ``` -## 3. Tree and Nodes +## Tree and Nodes - Base class **NodeBase** ```cpp template diff --git a/design_doc/model_interface.md b/design_doc/model_interface.md index be65c90..7db8fc8 100644 --- a/design_doc/model_interface.md +++ b/design_doc/model_interface.md @@ -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): diff --git a/design_doc/options.md b/design_doc/options.md index c71a34b..edfb4d7 100644 --- a/design_doc/options.md +++ b/design_doc/options.md @@ -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++) diff --git a/design_doc/sampler.md b/design_doc/sampler.md index 88cb7e2..351fa91 100644 --- a/design_doc/sampler.md +++ b/design_doc/sampler.md @@ -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. diff --git a/design_doc/trainer.md b/design_doc/trainer.md index b644f0d..e35fb43 100644 --- a/design_doc/trainer.md +++ b/design_doc/trainer.md @@ -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, ...):