add the interface in engine.py

This commit is contained in:
rtz19970824 2018-01-12 21:48:01 +08:00
parent 68cc63144f
commit fcaa571b42
2 changed files with 17 additions and 1 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ checkpoint
.DS_Store .DS_Store
data data
.log .log
go-*

View File

@ -5,6 +5,7 @@
# $Author: renyong15 © <mails.tsinghua.edu.cn> # $Author: renyong15 © <mails.tsinghua.edu.cn>
# #
import sys
from game import Game from game import Game
import copy import copy
import numpy as np import numpy as np
@ -187,9 +188,23 @@ class GTPEngine():
board = board.flatten().tolist() board = board.flatten().tolist()
return board, True return board, True
def cmd_print_board(self, args, **kwargs):
board = copy.deepcopy(self._game.board)
print(board)
return None, True
def cmd_get_prob(self, args, **kwargs): def cmd_get_prob(self, args, **kwargs):
return self._game.prob, True return self._game.prob, True
if __name__ == "main": if __name__ == "__main__":
print ("test engine.py") print ("test engine.py")
game = Game(name='reversi')
engine = GTPEngine(game_obj=game)
print ("Engine initialized!")
cmd = raw_input
while not engine.disconnect:
command = cmd()
result = engine.run_cmd(command)
sys.stdout.write(result)
sys.stdout.flush()