Windows下编译配置丽拉围棋Leela Zero

Leela zero是比利时程序员Gian-Carlo Pascutto(GCP)参照DeepMind最新论文在github上面开展的的一款开源围棋项目,项目为分布式,依靠志愿者提供算力。不借助任何人类知识,完全从零开始,致力于复现Alphagozero。

众多棋友都很好奇,究竟如何在自己个人电脑上配置属于自己的丽拉?希望这篇文章能为对计算机不甚了解的棋友,提供一些帮助。

1.下载相关文件 
       ①Leela Zero: https://github.com/gcp/leela-zero

这是Leela的作者GCP在Github上提交的源文件(如果对计算机比较了解的朋友,看GCP的readme应该就能自己配置好了)。进入网页,通过绿色的download键,把压缩包下载至自己的电脑。

②LeelaSabaki: https://github.com/SabakiHQ/LeelaSabaki

同理,下载压缩包并解压。

③Sabaki: https://github.com/SabakiHQ/Sabaki/releases/tag/v0.33.4

Sabaki是一个帮助完成交互的围棋软件,链接内提供了多个操作系统下的安装包,此文默认为使用windows系统。

④Leela权重文件: 权重文件的链接可在①的readme中找到(http://zero.sjeng.org/best-network),直接下载即可。把下载好的权重文件(txt格式)放在②文件的相同根目录下。

  1. 编译Leela
    首先需要对下载的①文件进行编译,作者提供了windows下使用Visual Studio 2015/2017编译的project文件(没有安装VS的朋友需要自行下载)。工程文件的下载路径如下 F:\Weiqi\Leela\leela-zero-master\msvc (前面的路径自行调整)

编译过程中值得注意的是,我起初一直使用debug模式编译,经常会出问题,最后使用了release模式编译。源文件是没有问题的,如果编译出错大概率是自己电脑内缺少了一些文件,自行百度即可解决问题。

如果编译成功,会在文件夹F:\Weiqi\Leela\leela-zero-master\msvc\x64\Release 下生成一个.exe文件,这就是我们需要在sabaki内添加的引擎之一。

  • 配置路径
    打开Sabaki,Engines -> Manage Engines,把我们的Engine路径添加进去即可。如下图所示:

第一行是用户自己给它起的名称,可随意。

第二行是leelasabaki的路径。

第三行是leela zero的路径和权重,按照自己电脑内的路径调整即可。我的路径如下:

–heatmap F:\Weiqi\Leela\leela-zero-master\msvc\x64\Release\leelaz.exe -w weight.txt –playouts 100 –noponder

  1. 开始游戏

在Sabaki内 File -> New, 开始一局棋,可以选择黑白使用的Engine,设置为Leela即可。

Generic options:
  -h [ --help ]                         Show commandline options.
  -g [ --gtp ]                          Enable GTP mode.
  -t [ --threads ] arg (=0)             Number of threads to use. Select 0 to
                                        let leela-zero pick a reasonable
                                        default.
  -p [ --playouts ] arg                 Weaken engine by limiting the number of
                                        playouts. Requires --noponder.
  -v [ --visits ] arg                   Weaken engine by limiting the number of
                                        visits.
  -b [ --lagbuffer ] arg (=100)         Safety margin for time usage in
                                        centiseconds.
  -r [ --resignpct ] arg (=-1)          Resign when winrate is less than x%.
                                        -1 uses 10% but scales for handicap.
  -w [ --weights ] arg (=D:\Leela Zero\iGORobot\iGORobot\iGORobot\best-network)
                                        File with network weights.
  -l [ --logfile ] arg                  File to log input/output to.
  -q [ --quiet ]                        Disable all diagnostic output.
  --timemanage arg (=auto)              [auto|on|off|fast|no_pruning] Enable
                                        time management features.
                                        auto = no_pruning when using -n,
                                        otherwise on.
                                        on = Cut off search when the best move
                                        can't change, but use full time if
                                        moving faster doesn't save time.
                                        fast = Same as on but always plays
                                        faster.
                                        no_pruning = For self play training
                                        use.

  --noponder                            Disable thinking on opponent's time.
  --benchmark                           Test network and exit. Default args:
                                        -v3200 --noponder -m0 -t1 -s1.
  --cpu-only                            Use CPU-only implementation and do not
                                        use OpenCL device(s).

OpenCL device options:
  --gpu arg                             ID of the OpenCL device(s) to use
                                        (disables autodetection).
  --full-tuner                          Try harder to find an optimal OpenCL
                                        tuning.
  --tune-only                           Tune OpenCL only and then exit.
  --batchsize arg (=0)                  Max batch size.  Select 0 to let
                                        leela-zero pick a reasonable default.
  --precision arg                       Floating-point precision
                                        (single/half/auto).
                                        Default is to auto which automatically
                                        determines which one to use.

Self-play options:
  -n [ --noise ]                        Enable policy network randomization.
  -s [ --seed ] arg                     Random number generation seed.
  -d [ --dumbpass ]                     Don't use heuristics for smarter
                                        passing.
  -m [ --randomcnt ] arg (=0)           Play more randomly the first x moves.
  --randomvisits arg (=1)               Don't play random moves if they have <=
                                        x visits.
  --randomtemp arg (=1)                 Temperature to use for random move
                                        selection.

作者:

喜欢围棋和编程。

发表评论

邮箱地址不会被公开。