關於圍棋貼目的問題...

前陣子 AlphaGo 大獲全勝後放出了五十盤自戰棋譜 (兩台 AlphaGo 自己下),其實有件事情有點出乎大家意料,而在圍棋界被一直討論。就是在這五十盤裡,黑棋與白棋的勝率比是 12:38 (中國規則,黑棋貼 7.5 目的情況),明顯白棋有強大的優勢。

這個 7.5 目指的是,由於黑棋先下 (先手優勢),所以圍的地會比較多,為了彌補白棋後下的這個缺點,一般都會設計「貼目」這個規則。

交大資工的 CGI 團隊在上個月月底發了一篇論文 (參考「CGOS Whole Period Ratings for 19x19 Board」這邊的記錄,在有參加 CGOS 的團隊裡只輸新版的 Zen),討論 value network 的新想法:「Multi-Labelled Value Networks for Computer Go」。

他們對貼目的數量做了分析:

For the training data, we label on output ?? as follows. For each self-play game, first calculate territory difference ? at the end of the game. Then, based on the Chinese rule, label 1 (win) on ?? for all ? < ?, and -1 (lose) for all ? > ?. (Note that the draw case ? = ? is ignored in this paper since the komi is not an integer normally.) For example, if black occupies 7 more points of territory than white, the ?-komi game is considered a win for all ? < 7, and a loss for all ? > 7. Thus, in this case, a 7.5-komi game is a loss, and a 6.5-komi or 0.5-komi game is a win.

這個研究完全顛覆了目前職業棋手一般的理解。目前的理解是,貼 5.5 目是黑棋優勢,貼 7.5 目是白棋優勢 (所謂的大貼目時代)。

接下來應該會有更多的研究出來,圍棋界會不會反思貼目規則呢...

Linux 上跑電腦圍棋程式 (CGOS)

這邊講的不是對人下的,而是電腦之間的對弈。

目前大多數的對弈軟體會到「CGOS - A Go Server Just for Computers」這邊對弈,當然目前最紅的是一般 (人類) 正式比賽用的 19x19 棋盤,數子採用中國規則 (相當於貼 7.5 目)。

不過與常見的正式比賽比較不一樣的是採用包干制,每方限時 15 分鐘,超時就直接裁定敗,不過有個小例外:

CGOS silently adds a fraction of a second to each players clock for each move played.

要把圍棋程式接到 CGOS 上面需要兩段程式,一段是 Go Engine 本身要支援 Go Text Procotol (GTP),另外一段是把 GTP 接到 CGOS。

前面 Go Engine 的部份,目前不少圍棋軟體都有支援 GTP,像是 Leela 或是 Ray

後者一般會用 Python CGOS Client

其中比較特別的是 CGOS 的帳號密碼,帳號只允許 18 個字,另外沒有帳號申請系統,第一次用什麼帳號他就自動記錄起來,之後就要用這組。

# config.cfg
Common:
  KillFile = kill.txt

# First engine
GTPEngine:
  Name = Leela090-test
  CommandLine = ./leela090-gtp.sh

  ServerHost = yss-aya.com
  ServerPort = 6819
  ServerUser = Leela090-test
  ServerPassword = mypassword

  NumberOfGames = 1

  SGFDirectory = sgf

然後建立 sgf 目錄存棋譜後,用 python bin/cgosclient.py config.cfg 跑起來。當你 touch kill.txt 後,下一盤棋就會自己結束 (預設是一直下)。

再來是裡面提到的 leela090-gtp.sh

#!/bin/bash
exec /usr/bin/nice -n 20 $(dirname $0)/leela_090_linux_x64_opencl -g -t 8 -b 50 -q -l /tmp/leela090-gtp.log

這邊跑的是 OpenCL 版本,你也可以跑 CPU 版。其中 -g 是 GTP mode,-t 是 CPU thread 數量,-b 是 network latency penalty (避免超時),-q 是 quiet mode,-l 是 log。