Skip to content

Commit

Permalink
Merge pull request #4 from kobanium/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
kobanium authored Jan 26, 2023
2 parents ed6b18d + 07f6b2f commit 9ae8941
Show file tree
Hide file tree
Showing 16 changed files with 1,152 additions and 191 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": true
}
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
# TamaGo
TamaGoはPythonで実装された囲碁の思考エンジンです。
人間の棋譜を利用した教師あり学習とGumbel AlphaZero方式の強化学習をお試しできるプログラムとなる予定です。
現在はランダムな着手を返すプログラムとなっています。
現在はランダムな着手を返すプログラムとなっています。
Python 3.6で動作確認をしています。

# Requirements
|使用するパッケージ|用途|
|---|---|
|numpy|雑多な計算|
|click|コマンドライン引数の実装|

# License
ライセンスはApache License ver 2.0です。

# Todo list
- 碁盤の実装
- [x] 連のデータ構造の実装
- [ ] 3x3パターンのデータ構造の実装
- [ ] 着手履歴の実装
- [x] 連のデータ構造
- [x] 3x3パターンのデータ構造
- [x] 着手履歴
- [x] Zobrist Hash
- [x] Super Koの判定処理
- 探索部の実装
- [ ] 木とノードのデータ構造の実装
- [ ] モンテカルロ木探索の実装
- [ ] PUCT探索の実装
- [ ] Sequential Halving applied to tree探索の実装
- [ ] 木とノードのデータ構造
- [ ] モンテカルロ木探索
- [ ] クラシックなMCTS
- [ ] UCT
- [ ] RAVE
- [ ] ランダムシミュレーション
- [ ] PUCT探索
- [ ] Sequential Halving applied to tree探索
- [ ] CGOS対応
- 学習の実装
- [ ] SGFファイルの読み込み処理の実装
- [ ] PyTorchを利用した教師あり学習の実装
- [ ] PyTorchを利用したGumbel AlphaZero方式の強化学習の実装
- [x] SGFファイルの読み込み処理
- [ ] PyTorchを利用した教師あり学習
- [ ] PyTorchを利用したGumbel AlphaZero方式の強化学習
- GTPクライアントの実装
- 基本的なコマンド
- [x] プログラム情報の表示 : name, version, protocol_version
Expand All @@ -34,7 +43,7 @@ TamaGoはPythonで実装された囲碁の思考エンジンです。
- [x] 着手 : play, genmove
- [ ] コミの設定と取得 : komi, get_komi
- [x] コマンドの確認 : known_command, list_commands
- [ ] SGFファイルの読み込み : load_sgf
- [x] SGFファイルの読み込み : load_sgf
- 大会参加時に必要なコマンド
- [ ] 持ち時間の初期化 : time_settings
- [ ] 持ち時間の読み込み : time_left
Expand Down
6 changes: 5 additions & 1 deletion board/constant.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 碁盤に関する定数
"""碁盤に関する定数
"""
# 碁盤のサイズ
BOARD_SIZE = 9
# 盤外のサイズ
Expand All @@ -25,3 +26,6 @@
RESIGN = -1
# Go Text ProtocolのX座標の文字
GTP_X_COORDINATE = 'IABCDEFGHJKLMNOPQRSTUVWXYZ'

# 着手履歴の最大数
MAX_RECORDS = (BOARD_SIZE ** 2) * 3
39 changes: 22 additions & 17 deletions board/coordinate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""プログラム内部形式とGTP形式の座標変換処理。
"""
from board.constant import PASS, RESIGN, OB_SIZE, GTP_X_COORDINATE

class Coordinate:
Expand All @@ -23,19 +25,20 @@ def convert_from_gtp_format(self, pos):
"""
if pos.upper() == "PASS":
return PASS
elif pos.upper() == "RESIGN":

if pos.upper() == "RESIGN":
return RESIGN
else:
alphabet = pos.upper()[0]
x = 0
for i in range(self.board_size):
if GTP_X_COORDINATE[i + 1] is alphabet:
x = i
y = self.board_size - int(pos[1:])
pos = x + OB_SIZE + (y + OB_SIZE) * self.board_size_with_ob

return pos

alphabet = pos.upper()[0]
x_coord = 0
for i in range(self.board_size):
if GTP_X_COORDINATE[i + 1] is alphabet:
x_coord = i
y_coord = self.board_size - int(pos[1:])

pos = x_coord + OB_SIZE + (y_coord + OB_SIZE) * self.board_size_with_ob

return pos

def convert_to_gtp_format(self, pos):
"""プログラム内部の座標からGTP形式に変換する。
Expand All @@ -48,9 +51,11 @@ def convert_to_gtp_format(self, pos):
"""
if pos == PASS:
return "PASS"
elif pos == RESIGN:

if pos == RESIGN:
return "RESIGN"
else:
x = pos % self.board_size_with_ob - OB_SIZE + 1
y = self.board_size - (pos // self.board_size_with_ob - OB_SIZE)
return (GTP_X_COORDINATE[x] + str(y))

x_coord = pos % self.board_size_with_ob - OB_SIZE + 1
y_coord = self.board_size - (pos // self.board_size_with_ob - OB_SIZE)

return GTP_X_COORDINATE[x_coord] + str(y_coord)
Loading

0 comments on commit 9ae8941

Please sign in to comment.