add the interface in engine.py
This commit is contained in:
parent
68cc63144f
commit
fcaa571b42
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ checkpoint
|
||||
.DS_Store
|
||||
data
|
||||
.log
|
||||
go-*
|
||||
|
@ -5,6 +5,7 @@
|
||||
# $Author: renyong15 © <mails.tsinghua.edu.cn>
|
||||
#
|
||||
|
||||
import sys
|
||||
from game import Game
|
||||
import copy
|
||||
import numpy as np
|
||||
@ -187,9 +188,23 @@ class GTPEngine():
|
||||
board = board.flatten().tolist()
|
||||
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):
|
||||
return self._game.prob, True
|
||||
|
||||
|
||||
if __name__ == "main":
|
||||
if __name__ == "__main__":
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user