Giter Club home page Giter Club logo

mugo's Introduction

Update

This repo is abandoned as of mid-2017. The code at https://github.com/tensorflow/minigo is a continuation of the work here.

MuGo: A minimalist Go engine modeled after AlphaGo

This is a pure Python implementation of the essential parts of AlphaGo.

The logic / control flow of AlphaGo itself is not very complicated and is replicated here. The secret sauce of AlphaGo is in its various neural networks.

(As I understand it) AlphaGo uses three neural networks during play. The first NN is a slow but accurate policy network. This network is trained to predict human moves (~57% accuracy), and it outputs a list of plausible moves, with probabilities attached to each move. This first NN is used to seed the Monte Carlo tree search with plausible moves. One of the reasons this first NN is slow is because of its size, and because the inputs to the neural network are various expensive-to-compute properties of the Go board (liberty counts; ataris; ladder status; etc.). The second NN is a smaller, faster but less accurate (~24% accuracy) policy network, and doesn't use computed properties as input. Once a leaf node of the current MCTS tree is reached, the second faster network is used to play the position out to the end with vaguely plausible moves, and score the end position. The third NN is a value network: it outputs an expected win margin for that board, without attempting to play anything out. The results of the monte carlo playout using NN #2 and the value calculation using NN #3 are averaged, and this value is recorded as the approximate result for that MCTS node.

Using the priors from NN #1 and the accumulating results of MCTS, a new path is chosen for further Monte Carlo exploration.

Getting Started

Install Tensorflow

Start by installing Tensorflow along with GPU drivers (i.e. CUDA support for Nvidia cards).

Get SGFs for supervised learning

Second, find a source of SGF files. You can find 15 years of KGS high-dan games at u-go.net. Alternately, you can download a database of professional games from a variety of sources.

Preprocess SGFs

Third, preprocess the SGF files. This takes all positions in the SGF files and extracts features for each position, as well as recording the correct next move. These positions are then split into chunks, with one test chunk and the remainder as training chunks. This step may take a while, and must be repeated if you change the feature extraction steps in features.py

python main.py preprocess data/kgs-*

(This example takes advantage of bash wildcard expansion - say, if the KGS directories are named data/kgs-2006-01, data/kgs-2006-02, and so on.)

Supervised learning (policy network)

With the preprocessed SGF data (default output directory is ./processed_data/), you can train the policy network.

python main.py train processed_data/ --save-file=/tmp/savedmodel --epochs=1 --logdir=logs/my_training_run

As the network is trained, the current model will be saved at --save-file. You can resume training the same network as follows:

python main.py train processed_data/ --read-file=/tmp/savedmodel
 --save-file=/tmp/savedmodel --epochs=10 --logdir=logs/my_training_run

Additionally, you can follow along with the training progress with TensorBoard - if you give each run a different name (logs/my_training_run, logs/my_training_run2), you can overlay the runs on top of each other.

tensorboard --logdir=logs/

Play against MuGo

MuGo uses the GTP protocol, and you can use any gtp-compliant program with it. To invoke the raw policy network, use

python main.py gtp policy --read-file=/tmp/savedmodel

To invoke the MCTS-integrated version of the policy network, use

python main.py gtp mcts --read-file=/tmp/savedmodel

One way to play via GTP is to use gogui-display (which implements a UI that speaks GTP.) You can download the gogui set of tools at http://gogui.sourceforge.net/. See also documentation on interesting ways to use GTP.

gogui-twogtp -black 'python main.py gtp policy --read-file=/tmp/savedmodel' -white 'gogui-display' -size 19 -komi 7.5 -verbose -auto

Another way to play via GTP is to play against GnuGo, while spectating the games

BLACK="gnugo --mode gtp"
WHITE="python main.py gtp policy --read-file=/tmp/savedmodel"
TWOGTP="gogui-twogtp -black \"$BLACK\" -white \"$WHITE\" -games 10 \
  -size 19 -alternate -sgffile gnugo"
gogui -size 19 -program "$TWOGTP" -computer-both -auto

Another way to play via GTP is to connect to CGOS, the Computer Go Online Server. The CGOS server hosted by boardspace.net is actually abandoned; you'll want to connect to the CGOS server at yss-aya.com.

After configuring your cgos.config file, you can connect to CGOS with cgosGtp -c cgos.config and spectate your own game with cgosView yss-aya.com 6819

Running unit tests

python -m unittest discover tests

mugo's People

Contributors

brilee avatar cpeterso avatar prak9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mugo's Issues

Training failed, has no attribute 'mul'

(tf3.4) cong@jsjc-PowerEdge-T630:~/Downloads/MuGo$ python main.py train processed_data --save-file=tmp/savedmodel1 --epochs=1 --logdir=logs/my_training_run
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
File "main.py", line 94, in
argh.dispatch(parser)
File "/home/cong/anaconda3/envs/tf3.4/lib/python3.4/site-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/home/cong/anaconda3/envs/tf3.4/lib/python3.4/site-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/home/cong/anaconda3/envs/tf3.4/lib/python3.4/site-packages/argh/dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "main.py", line 72, in train
n = PolicyNetwork()
File "/home/cong/Downloads/MuGo/policy.py", line 49, in init
self.set_up_network()
File "/home/cong/Downloads/MuGo/policy.py", line 90, in set_up_network
log_likelihood_cost = -tf.reduce_mean(tf.reduce_sum(tf.mul(tf.log(output), y), reduction_indices=[1]))
AttributeError: 'module' object has no attribute 'mul'

I am sure that preprocessing work is done, and trunk files are stored at processed_data.
I use ubuntu 14.04 LTS, anaconda environment, python3.4. argh,sfg has been in the 'conda list' result.

Move "Q16" from engine is not a legal move (ko rule violation).

Hey, could you mabye add a check for the ko rule?

tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . X . . . 18 
17 . . . . . . . . . . . . . X . X X . . 17 
16 . . X . . . . . . . . . . . X O<X . . 16 
15 . . . . . . . . . . . . . . O * O O . 15 
14 . . . . . . . . . . . . . . . O X . . 14 
13 . . . . . . . . . . . . . . . O X X X 13 
12 . . . . . . . . . . . . . . . . O O . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . . . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . O . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . X . . . . . . . . . . . . . X . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . O . O . . . . . . . O . O . . .  4 
 3 . . . . . X O . . . . O . X . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 32. Captures X: 1 O: 1

max rollout depth exceeded!
value: 4.5
tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . X . . . 18 
17 . . . . . . . . . . . . . X . X X . . 17 
16 . . X . . . . . . . . . . . X * X . . 16 
15 . . . . . . . . . . . . . . O X<O O . 15 
14 . . . . . . . . . . . . . . . O X . . 14 
13 . . . . . . . . . . . . . . . O X X X 13 
12 . . . . . . . . . . . . . . . . O O . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . . . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . O . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . X . . . . . . . . . . . . . X . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . O . O . . . . . . . O . O . . .  4 
 3 . . . . . X O . . . . O . X . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 33. Captures X: 2 O: 1

max rollout depth exceeded!
value: -4.5
Jun 29, 2017 7:55:35 PM com.gokgs.client.gtp.GtpClient protocolEvent
SEVERE: Error from GTP Communications layer, closing down.
org.igoweb.go.gtp.GtpException: Move "Q16" from engine is not a legal move (ko rule violation).

AttributeError: 'PolicyNetwork' object has no attribute 'output'

Hello, I am getting this error while trying to generate a move.

Traceback (most recent call last):
  File "main.py", line 109, in <module>
    argh.dispatch(parser)
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 260, in _call
    result = function(*positional, **keywords)
  File "main.py", line 51, in gtp
    engine_reply = gtp_engine.send(cmd)
  File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 154, in send
    message_id, getattr(self, "cmd_" + command)(arguments))
  File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 222, in cmd_genmove
    move = self._game.get_move(c)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 81, in get_move
    move = self.suggest_move(self.position)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 233, in suggest_move
    move_probs = self.policy_network.run(position)
  File "/home/mrmartinke/Desktop/MuGo-master/policy.py", line 152, in run
    probabilities = self.session.run(self.output, feed_dict={self.x: processed_position[None, :]})[0]
AttributeError: 'PolicyNetwork' object has no attribute 'output'

NameError: name 'find_sgf_files' is not defined

Traceback (most recent call last):
File "main.py", line 103, in
argh.dispatch(parser)
File "C:\Users\LEO\AppData\Local\Programs\Python\Python35\lib\site-packages\ar
for line in lines:
File "C:\Users\LEO\AppData\Local\Programs\Python\Python35\lib\site-packages\ar
for line in result:
File "C:\Users\LEO\AppData\Local\Programs\Python\Python35\lib\site-packages\ar
result = function(*positional, **keywords)
File "main.py", line 49, in preprocess
sgf_files = list(find_sgf_files(*data_sets))
NameError: name 'find_sgf_files' is not defined

AttributeError: 'NoneType' object has no attribute 'to_play'

when run "python3 main.py preprocess data/other/tmp/" i get this error info:
3 sgfs found.
Estimated number of chunks: 0
Traceback (most recent call last):
File "main.py", line 94, in
argh.dispatch(parser)
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "main.py", line 49, in preprocess
test_chunk, training_chunks = parse_data_sets(*data_sets)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 140, in parse_data_sets
test_chunk, training_chunks = split_test_training(positions_w_context, est_num_positions)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 60, in split_test_training
positions_w_context = list(positions_w_context)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 52, in get_positions_from_sgf
for position_w_context in replay_sgf(f.read()):
File "/mnt/ken-volume/MuGo/sgf_wrapper.py", line 133, in replay_sgf
maybe_correct_next(pos, current_node.next)
File "/mnt/ken-volume/MuGo/sgf_wrapper.py", line 97, in maybe_correct_next
('W' in next_node.properties and not pos.to_play == go.WHITE)):
AttributeError: 'NoneType' object has no attribute 'to_play'

NameError: name 'copy' is not defined

Hello, I am getting an error while trying to run mcts.

tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . . . . . 18 
17 . . . . . . . . . . . . . . . . . . . 17 
16 . . . . . . . . . . . . . . . X O<. . 16 
15 . . . . . . . . . . . . . . . . . . . 15 
14 . . . . . . . . . . . . . . . . . . . 14 
13 . . . . . . . . . . . . . . . . . . . 13 
12 . . . . . . . . . . . . . . . . . . . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . . . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . . . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . . . . . . . . . . . . . . . . . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . . . . . . . . . . . . . . . . .  4 
 3 . . . . . . . . . . . . . . . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 2. Captures X: 0 O: 0

Traceback (most recent call last):
  File "main.py", line 109, in <module>
    argh.dispatch(parser)
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 260, in _call
    result = function(*positional, **keywords)
  File "main.py", line 51, in gtp
    engine_reply = gtp_engine.send(cmd)
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/gtp.py", line 154, in send
    message_id, getattr(self, "cmd_" + command)(arguments))
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/gtp.py", line 222, in cmd_genmove
    move = self._game.get_move(c)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 81, in get_move
    move = self.suggest_move(self.position)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 236, in suggest_move
    self.tree_search(root)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 256, in tree_search
    value = self.estimate_value(root, chosen_leaf)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 265, in estimate_value
    current = copy.deepcopy(leaf_position)
NameError: name 'copy' is not defined

MCTS does not work

python main.py gtp policy --read-file=tmp\savedmodel This command is OK
python main.py mcts policy --read-file=tmp\savedmodel not work
fix the bug.Thank you

Group ID overflowed

When using mcts, the program crashed and returned KeyError: -32768 in function _update_liberties group = self.groups[group_id]. Is this a bug of code?

SelfPlay Illegal Move

Traceback (most recent call last):
File "selfplay.py", line 43, in
winners, losers = extract_moves(positions)
File "selfplay.py", line 32, in extract_moves
sgf_wrapper.replay_position(final_position))
File "/home/mrmartinke/Desktop/MuGo-master/utils.py", line 67, in take_n
return list(itertools.islice(iterable, n))
File "/home/mrmartinke/Desktop/MuGo-master/sgf_wrapper.py", line 174, in replay_position
pos = pos.play_move(next_move, color=color)
File "/home/mrmartinke/Desktop/MuGo-master/go.py", line 354, in play_move
raise IllegalMove("Move at {} is illegal: \n{}".format(c, self))
go.IllegalMove: Move at (16, 1) is illegal:

MCTS error

Plicy works fine.
C:\MuGo>python main.py gtp policy --read-file=model\savedmodel
GTP engine ready
genmove b (I type)
= Q16

MCTS does not work. Error messages as below.
C:\MuGo>python main.py gtp mcts --read-file=model\savedmodel
GTP engine ready
genmove b (I type)
tree search
Traceback (most recent call last):
File "main.py", line 94, in
argh.dispatch(parser)
File "c:\python35\lib\site-packages\argh\dispatching.py", line 174, in dispatch
for line in lines:
File "c:\python35\lib\site-packages\argh\dispatching.py", line 277, in _execute_command
for line in result:
File "c:\python35\lib\site-packages\argh\dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "main.py", line 40, in gtp
engine_reply = gtp_engine.send(cmd)
File "c:\python35\lib\site-packages\pygtp-0.2-py3.5.egg\gtp.py", line 154, in send
File "c:\python35\lib\site-packages\pygtp-0.2-py3.5.egg\gtp.py", line 222, in cmd_genmove
File "C:\MuGo\strategies.py", line 81, in get_move
move = self.suggest_move(self.position)
File "C:\MuGo\strategies.py", line 236, in suggest_move
self.tree_search(root)
File "C:\MuGo\strategies.py", line 246, in tree_search
position = chosen_leaf.compute_position()
File "C:\MuGo\strategies.py", line 183, in compute_position
self.position = self.parent.position.play_move(self.move)
TypeError: play_move() missing 1 required positional argument: 'c'

TypeError: <lambda>() missing 1 required positional argument: 'root'

tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . . . . . 18 
17 . . . . . . . . . . . . . . . . . . . 17 
16 . . . . . . . . . . . . . . . O<. . . 16 
15 . . . . . . . . . . . . . . . . . . . 15 
14 . . . . . . . . . . . . . . . . . . . 14 
13 . . . . . . . . . . . . . . . . . . . 13 
12 . . . . . . . . . . . . . . . . . . . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . X . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . . . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . . . . . . . . . . . . . . . . . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . . . . . . . . . . . . . . . . .  4 
 3 . . . . . . . . . . . . . . . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 2. Captures X: 0 O: 0

max rollout depth exceeded!
value: -54.5
tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . . . . . 18 
17 . . . . . . . . . . . . . . . . . . . 17 
16 . . . . . . . . . . . . . . . . O<. . 16 
15 . . . . . . . . . . . . . . . . . . . 15 
14 . . . . . . . . . . . . . . . . . . . 14 
13 . . . . . . . . . . . . . . . . . . . 13 
12 . . . . . . . . . . . . . . . . . . . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . X . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . . . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . . . . . . . . . . . . . . . . . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . . . . . . . . . . . . . . . . .  4 
 3 . . . . . . . . . . . . . . . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 2. Captures X: 0 O: 0

max rollout depth exceeded!
value: 33.5
tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . . . . . 18 
17 . . . . . . . . . . . . . . . . . . . 17 
16 . . . . . . . . . . . . . . . . O . . 16 
15 . . . . . . . . . . . . . . . . . . . 15 
14 . . . . . . . . . . . . . . . . . . . 14 
13 . . . . . . . . . . . . . . . . . . . 13 
12 . . . . . . . . . . . . . . . . . . . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . X . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . . . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . . . . . . . . . . . . . . . . . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . X<. . . . . . . . . . . . . . .  4 
 3 . . . . . . . . . . . . . . . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 3. Captures X: 0 O: 0

max rollout depth exceeded!
value: -33.5
tree search
Investigating following position:
   A B C D E F G H J K L M N O P Q R S T   
19 . . . . . . . . . . . . . . . . . . . 19 
18 . . . . . . . . . . . . . . . . . . . 18 
17 . . . . . . . . . . . . . . . . . . . 17 
16 . . . X<. . . . . . . . . . . . O . . 16 
15 . . . . . . . . . . . . . . . . . . . 15 
14 . . . . . . . . . . . . . . . . . . . 14 
13 . . . . . . . . . . . . . . . . . . . 13 
12 . . . . . . . . . . . . . . . . . . . 12 
11 . . . . . . . . . . . . . . . . . . . 11 
10 . . . . . . . . . . . . . . . . . . . 10 
 9 . . . . . . . X . . . . . . . . . . .  9 
 8 . . . . . . . . . . . . . . . . . . .  8 
 7 . . . . . . . . . . . . . . . . . . .  7 
 6 . . . . . . . . . . . . . . . . . . .  6 
 5 . . . . . . . . . . . . . . . . . . .  5 
 4 . . . . . . . . . . . . . . . . . . .  4 
 3 . . . . . . . . . . . . . . . . . . .  3 
 2 . . . . . . . . . . . . . . . . . . .  2 
 1 . . . . . . . . . . . . . . . . . . .  1 
   A B C D E F G H J K L M N O P Q R S T   
Move: 3. Captures X: 0 O: 0

value: -46.5
Traceback (most recent call last):
  File "main.py", line 109, in <module>
    argh.dispatch(parser)
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/home/mrmartinke/.local/lib/python3.5/site-packages/argh/dispatching.py", line 260, in _call
    result = function(*positional, **keywords)
  File "main.py", line 51, in gtp
    engine_reply = gtp_engine.send(cmd)
  File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 154, in send
    message_id, getattr(self, "cmd_" + command)(arguments))
  File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 222, in cmd_genmove
    move = self._game.get_move(c)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 85, in get_move
    move = self.suggest_move(self.position)
  File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 243, in suggest_move
    return max(root.children.keys(), key=lambda move, root: root.children[move])
TypeError: <lambda>() missing 1 required positional argument: 'root'

same game again and again

Hi there,

Thanks for developing this wonderful tools. But I have a question: when I let Mugo match against itself, the game of each time is exactly same. How to let Mugos play differently?

Thanks again.

handicap=int(sgf_prop(props.get('HA', [0]))) ValueError: invalid literal for int() with base 10: '吴受先'

when i run "python3 main.py preprocess data/other/tmp/wuqingyuan/" get this error info:
366 sgfs found.
Estimated number of chunks: 17
Traceback (most recent call last):
File "main.py", line 94, in
argh.dispatch(parser)
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "main.py", line 49, in preprocess
test_chunk, training_chunks = parse_data_sets(*data_sets)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 140, in parse_data_sets
test_chunk, training_chunks = split_test_training(positions_w_context, est_num_positions)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 60, in split_test_training
positions_w_context = list(positions_w_context)
File "/mnt/ken-volume/MuGo/load_data_sets.py", line 52, in get_positions_from_sgf
for position_w_context in replay_sgf(f.read()):
File "/mnt/ken-volume/MuGo/sgf_wrapper.py", line 124, in replay_sgf
handicap=int(sgf_prop(props.get('HA', [0]))),
ValueError: invalid literal for int() with base 10: '吴受先'

it's look same sgf file props.ge('HA',[0]) get a string ,not a int.

IllegalMove

When I connect the robot to CGBAN,
It often says IllegalMove
and ended the program

I think the problem is the Go Rule,
But what Rule the Mugo use (Chinese? Japanese?)?

AttributeError: module 'gtp' has no attribute 'RESIGN'

error info when run "gogui-twogtp -black 'python3 main.py gtp policy --read-file=./tmp/savedmodel' -white 'gogui-display' -size 19 -komi 7.5 -verbose -auto":

B>> genmove b
Traceback (most recent call last):
File "main.py", line 81, in
argh.dispatch(parser)
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/usr/local/lib/python3.5/dist-packages/argh/dispatching.py", line 260, in call
result = function(*positional, **keywords)
File "main.py", line 38, in gtp
engine_reply = gtp_engine.send(cmd)
File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 151, in send
message_id, getattr(self, "cmd
" + command)(arguments))
File "/usr/local/lib/python3.5/dist-packages/gtp.py", line 219, in cmd_genmove
move = self._game.get_move(c)
File "/mnt/ken-volume/MuGo/strategies.py", line 60, in get_move
return utils.unparse_pygtp_coords(move)
File "/mnt/ken-volume/MuGo/utils.py", line 41, in unparse_pygtp_coords
if c == gtp.RESIGN:
AttributeError: module 'gtp' has no attribute 'RESIGN'
B>> final_score
W>> final_score
W<< ? unknown command: final_score
W<<
B>> quit
W>> quit
W<< =
W<<
Black program died

system :ubuntu 16.04

About how to fix argument problem.

At running
gogui-twogtp -black 'python3 main.py gtp policy --read -file=/tmp/' -white 'gogui-display' -size 19 -komi 7.5 -verbose -auto
there is a argument problem.
main.py gtp: error: argument -r/--read-file: expected one argument
i don't know where the argument should be.
if anyone konw it,please help me.i will appreciate it very much.

tensorflow.python.framework.errors_impl.NotFoundError: Key RL_global_step not found in checkpoint

tensorflow version: 1.3 (CPU)
When I run : python main.py gtp policy --read-file=saved_models/20170718

It causes an error:
tensorflow.python.framework.errors_impl.NotFoundError: Key RL_global_step not fo
und in checkpoint
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_INT32], _device="/job:loc
alhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names
, save/RestoreV2/shape_and_slices)]]
How to fix it.

Is the rollout fastNet implemented?

Hello, really nice work. Is the rollout fastNet implemented? I see in the code that it's simply replaced by the full policy net. Why not use a fast rollout net as said in the paper?

preprocess error

Nice project! unfortunately i encountered an error and am not sure what goes wrong.
I downloaded the master branch yesterday.
the command i use: python main.py preprocess data/*
python version 3.5 ( tested 3.4 )

somehow 0 positions are allocated as test but i can't find out why

124966 sgfs found. Estimated number of chunks: 6101 Allocating 0 positions as test; remainder as training Writing test chunk Traceback (most recent call last): File "main.py", line 79, in <module> argh.dispatch(parser) File "/home/boss/anaconda3/envs/tensorflow35/lib/python3.5/site-packages/argh/dispatching.py", line 174, in dispatch for line in lines: File "/home/boss/anaconda3/envs/tensorflow35/lib/python3.5/site-packages/argh/dispatching.py", line 277, in _execute_command for line in result: File "/home/boss/anaconda3/envs/tensorflow35/lib/python3.5/site-packages/argh/dispatching.py", line 260, in _call result = function(*positional, **keywords) File "main.py", line 45, in preprocess process_raw_data(*data_sets, processed_dir=processed_dir) File "/home/boss/Downloads/CNN-Play/MuGo-master/load_data_sets.py", line 154, in process_raw_data test_dataset = DataSet.from_positions_w_context(test_chunk, is_test=True) File "/home/boss/Downloads/CNN-Play/MuGo-master/load_data_sets.py", line 106, in from_positions_w_context positions, next_moves, results = zip(*positions_w_context) ValueError: not enough values to unpack (expected 3, got 0)

reverted the "rewrite onehot methods for small improvement" commit, error message:
ValueError: need more than 0 values to unpack

SyntaxError: invalid syntax

$ python main.py preprocess games/*
  File "main.py", line 42
    def preprocess(*data_sets, processed_dir="processed_data"):
                                           ^
SyntaxError: invalid syntax

Using:

$ python --version
Python 2.7.12

Type of self.output in policy.py

Hey @brilee ,

I'm trying to play against this wonderful library. However when I'm trying genmove b I'm getting:

File "\MuGo\policy.py", line 152, in run
probabilities = self.session.run(self.output, feed_dict={self.x: processed_position[None, :]})[0]
AttributeError: 'PolicyNetwork' object has no attribute 'output'

What should self.output be ?

Error when prepossessing Chinese SGF

When there are Chinese characters in SGF, then I got an error message:

result = function(*positional, **keywords)
File "main.py", line 53, in preprocess
test_dataset = DataSet.from_positions_w_context(test_chunk, is_test=True)
File "C:\Users\xxxx\Mugo\load_data_sets.py", line 83, in from_positions_w_context
positions, next_moves, results = zip(*positions_w_context)
ValueError: not enough values to unpack (expected 3, got 0)

max rollout depth exceeded! import copy rasied it ?

when i want to use mtcs to play ,it rasied error :
File "/home/mrmartinke/Desktop/MuGo-master/strategies.py", line 265, in estimate_value
current = copy.deepcopy(leaf_position)
NameError: name 'copy' is not defined
so i import copy ,the game can run ,but it rasied this everytime :

Move: 4. Captures X: 0 O: 0
max rollout depth exceeded!
value: 23.0
tree search
thanks for your help!

What hardware i need to build and develop Mugo.

It's exciting to get MuGo(a personal Alphago) in PCs. Thank your work! I'm interested in your work. I have a pc with Intel I5-4590, 8GB ram, GTX770(1253 cudas). And i have tens of thousand professional SGFs ready to be training. If I want to train 100,000 SGFs with my hardware using Mugo, how long i need training. I learned for Deep Learning hardware GPU is more important than CPUs and High cpu frequency is more important than multi-threads and cores cpu has, is it right? Please give me some advice about hardware configuration. Thank you!

AttributeError: 'PolicyNetwork' object has no attribute 'output'

3 play black D5
=3

4 genmove white
Traceback (most recent call last):
File "main.py", line 109, in
argh.dispatch(parser)
File "D:\Python\lib\site-packages\argh\dispatching.py", line 174, in dispatch
for line in lines:
File "D:\Python\lib\site-packages\argh\dispatching.py", line 277, in _execute_command
for line in result:
File "D:\Python\lib\site-packages\argh\dispatching.py", line 260, in call
result = function(*positional, **keywords)
File "main.py", line 51, in gtp
engine_reply = gtp_engine.send(cmd)
File "D:\Python\lib\site-packages\gtp.py", line 154, in send
message_id, getattr(self, "cmd
" + command)(arguments))
File "D:\Python\lib\site-packages\gtp.py", line 222, in cmd_genmove
move = self._game.get_move(c)
File "D:\MuGo-master\MuGo-master\strategies.py", line 81, in get_move
move = self.suggest_move(self.position)
File "D:\MuGo-master\MuGo-master\strategies.py", line 115, in suggest_move
move_probabilities = self.policy_network.run(position)
File "D:\MuGo-master\MuGo-master\policy.py", line 152, in run
probabilities = self.session.run(self.output, feed_dict={self.x: processed_position[None, :]})[0]
AttributeError: 'PolicyNetwork' object has no attribute 'output'

could you help me to load MuGo in gtp gui like Sabaki?

i load it well in Gogui ,but when i want to load it to vs other ai ,Gogui cant do it well,so i load it in Sabaki,but the parameter seems dont work ,gungo work well in Sabaki,thanks a lot for your help!
here is gogui load
commond:python main.py gtp policy --read-file=tmp\savedmodel
working directory C:\Users\allen\Downloads\MuGo-master\MuGo-master

and here is Sabaki:
working directory C:\Users\allen\Downloads\MuGo-master\MuGo-master\main.py
commond python main.py gtp policy --read-file=C:\Users\allen\Downloads\MuGo-master\MuGo-master\tmp\savedmodel

what the "capture size" means?

I read your paper, I don't understand Capture Size, if at state S(t), we get a result A(t), is the Capture size the result of the move A(t) ? or the result of move A(t-1)? and about liberties after move, is it the same as capture size? thanks.

NameError: name 'protocol_version' is not defined

I run this program by using:
gogui-twogtp -black 'python main.py gtp policy --read-file=/tmp/savedmodel' -white 'gogui-display' -size 19 -komi 7.5 -verbose -auto

My machine meets all those requirements (gtp....);
and the Error goes here:
GTP engine ready
Traceback (most recent call last):
File "main.py", line 94, in
argh.dispatch(parser)
File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 174, in dispatch
for line in lines:
File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 277, in _execute_command
for line in result:
File "/usr/local/lib/python2.7/site-packages/argh/dispatching.py", line 260, in _call
result = function(*positional, **keywords)
File "main.py", line 31, in gtp
inpt = input()
File "", line 1, in
NameError: name 'protocol_version' is not defined
B>> name
B>> version
B>> list_commands
The Go program terminated unexpectedly.

About how to play MuGo

At running
python main.py gtp policy --read-file=saved_models/20170718'
it appeared that
AttributeError: module 'gtp' has no attribute 'Engine' .

Besides, when I ran the code
`gogui-twogtp -black 'python main.py gtp policy --read-file=saved_models/20170718' -white 'gogui-display'-size 19 -komi 7.5 -verbose -auto
in cmd it will be
Unknown option --read-file=saved_models/20170718'

I will appreciate it if anyone could help me!

Error while prerunning it

[del]I did install things included in the 'requirements.txt'.
But it seems didn't work when I commanded 'python main.py gtp policy --read-file=saved_models/20170718'.

File "main.py", line 44
def preprocess(*data_sets, processed_dir="processed_data"):
^
The '^' is pointing to the last letter of 'processed_dir'.
SyntaxError: invalid syntax

I tried to solve it but just not worked.
And need your help.

Thanks.[/del]

It's okay. I solved it.
Marvellous work. Thanks again.

Error when start training

python main.py train processed_data/ --save-file=/tmp/savedmodel --epochs=1 --logdir=logs/my_training_run

untitled

SelfPlay Illegal Move

here is traceback,i will be grateful if you can help me!
Traceback (most recent call last):
File "C:/Users/allen/Downloads/TaDing-MuGo-master/MuGo/selfplay.py", line 43, in
winners, losers = extract_moves(positions)
File "C:/Users/allen/Downloads/TaDing-MuGo-master/MuGo/selfplay.py", line 32, in extract_moves
sgf_wrapper.replay_position(final_position))
File "C:\Users\allen\Downloads\TaDing-MuGo-master\MuGo\utils.py", line 67, in take_n
return list(itertools.islice(iterable, n))
File "C:\Users\allen\Downloads\TaDing-MuGo-master\MuGo\sgf_wrapper.py", line 174, in replay_position
pos = pos.play_move(next_move, color=color)
File "C:\Users\allen\Downloads\TaDing-MuGo-master\MuGo\go.py", line 354, in play_move
raise IllegalMove("Move at {} is illegal: \n{}".format(c, self))
go.IllegalMove: Move at (7, 18) is illegal:
A B C D E F G H J K L M N O P Q R S T
19 . . . . . . . . . . . . . . . . . . . 19
18 . . . O . . . X . . . . . . X . . . . 18
17 . . X . . O . O O . . X X X O X X X . 17
16 . . . X . . . . . . . X O O O O O X . 16
15 . . . . . . . . . . X O X X X<O O O O 15
14 . . X . . . . . . . . O . . X O X X O 14
13 . . . . . . . . . . O . . X X O O X X 13
12 . . . . . . . . . . X X X . X X O X . 12
11 . . . . . . . . . X O O . X O O X X O 11
10 . . . . . . . . . . X O O O O O O X O 10
9 . . . . . . . . . . . X . . O X X X O 9
8 . . . . . . . . . . X . O X O X O O . 8
7 . . O . . . . . . . . . X O X X O X . 7
6 . O X . . . . . . . . . O O O O O . . 6
5 . O X O O . . . . O . . . . . . . O . 5
4 . . O X . X . . . . . . O X . X . X . 4
3 . O O X . O X . . . . . . X . . . . . 3
2 . O X X . . . . . . . X . . . . . . . 2
1 . X . . . . . . . . . . . . . . . . . 1
A B C D E F G H J K L M N O P Q R S T
Move: 122. Captures X: 0 O: 1

Process finished with exit code 1

preprocess error: Invalid syntax

Hello,

I downloaded the kgs to the directory ./data, and call the command:
python main.py preprocess ./data/*
Then I have the error:
File "main.py", line 42
def preprocess(*data_sets, processed_dir="./processed_data"):
^
SyntaxError: invalid syntax

It seems there is something wrong with the directory parsing (it doesn't work whether or not I add './' in front of 'processed_data'). Does anyone how to fix it? Thanks!

ImportError: No module named 'argh'

$ sudo -H pip install argh
Requirement already satisfied: argh in /usr/local/lib/python2.7/dist-packages

Then:

$ python3 main.py preprocess games/*
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import argh
ImportError: No module named 'argh'

Using 64-bit Xubuntu Linux:

$ python3 --version
Python 3.5.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.