Skip to content

Instantly share code, notes, and snippets.

@terakun
Created May 1, 2019 17:59
Show Gist options
  • Save terakun/77be08b7471359d6bebc2cffe446a58f to your computer and use it in GitHub Desktop.
Save terakun/77be08b7471359d6bebc2cffe446a58f to your computer and use it in GitHub Desktop.
QuoridorのPythonクライアントのテンプレート
import socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
port = 8080
ip = '127.0.0.1'
# サーバ/ポートを指定
s.connect((ip, port))
while True:
mesg = s.recv(1024) # メッセージを受信 (https://github.com/terakun/quoridor_judgeの入力形式に対応するバイト列が送られてくる)
print(mesg)
# ここでAIが次の手を計算する
op = 'next operation'
s.sendall(op.encode) # 手を送信 (https://github.com/terakun/quoridor_judgeの出力形式に対応するバイト列を送る)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment