5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu 16.04でAlphaZeroのアルゴリズムを使ったReversiを試してみる

Last updated at Posted at 2018-02-10

Ubuntu 16.04でAlphaZeroのアルゴリズムを使ったリバーシを試してみたのですが、依存関係でハマったのでメモ代わりに残しておきます。
まずpyenv + Condaの環境はこちらを参考にしました。
pyenv + anaconda + python3: https://qiita.com/sk427/items/9f215931c8249ada75cd
#pyenv + Condaの設定

pyenv-conda.sh

# pyenvの導入
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

# Anacondaの導入
pyenv install -l | grep ana #最新のパッケージを検索
pyenv install anaconda3-5.0.1
pyenv rehash
pyenv global anaconda3-5.0.1
echo 'export PATH="$PYENV_ROOT/versions/anaconda3-5.0.1/bin/:$PATH"' >> ~/.bashrc
source ~/.bashrc
conda update conda

Reversi-alpha-zeroのインストール

reversi-alpha-zero.sh

# 環境構築時wxPythonのビルドに必要な依存関係の解消
sudo apt-get install libgtk2.0-dev mesa-common-dev libglu1-mesa-dev python-gst0.10-dev libwebkit-dev
# Reversi-alpha-zeroの取得
git clone https://github.com/mokemokechicken/reversi-alpha-zero
# Conda仮想環境の構築
cd reversi-alpha-zero
cp requirements.txt conda-requirements.txt
conda env create -f environment.yml
source activate reversi-a0
# 追加の依存関係。pipで入れるよりもCondaのを使ったほうが楽に動かせる
conda install tensorflow-gpu==1.3 h5py

とりあえず、これで一通りの機能が使えるようになります。
もうひとつハマったのがGUIモードで動かす場合の共有ライブラリの読み込みに失敗する場合はLD_LIBRARY_PATHを指定しておく必要があるようです。(なぜpyenvで面倒みてくれないのか不思議)

GUIモードでの実行

play-gui.sh
LD_LIBRARY_PATH=~/.pyenv/versions/anaconda3-5.0.1/envs/reversi-a0/lib/python3.6/site-packages/wx python src/reversi_zero/run.py play_gui
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?