Continued implementation of functions needed for network play
This commit is contained in:
parent
f4680cc631
commit
c7947d9790
3 changed files with 96 additions and 26 deletions
|
@ -26,11 +26,14 @@ class NetworkThread(threading.Thread):
|
|||
self.socket = GTPSocket(socket)
|
||||
self.send_lock = threading.Lock()
|
||||
|
||||
GTPSocket.known_cmds = GTPSocket.known_cmds & set(dispatcher.keys())
|
||||
GTPSocket.known_cmds = GTPSocket.known_cmds & set(NetworkThread.dispatcher.keys())
|
||||
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
while True:
|
||||
gtp = self.socket.get()
|
||||
if gtp is not None:
|
||||
NetworkThread.dispatcher[gtp.command](gtp)
|
||||
|
||||
|
||||
def do_quit(self, gtp):
|
||||
|
@ -38,19 +41,31 @@ class NetworkThread(threading.Thread):
|
|||
|
||||
|
||||
def do_boardsize(self, gtp):
|
||||
pass
|
||||
with self.goban_lock:
|
||||
self.goban.set_board_size(int(gtp.arguments[0]))
|
||||
|
||||
|
||||
def do_clear_board(self, gtp):
|
||||
pass
|
||||
with self.goban_lock:
|
||||
self.goban.reset()
|
||||
|
||||
|
||||
def do_komi(self, gtp):
|
||||
pass
|
||||
with self.goban_lock:
|
||||
self.goban.komi = float(gtp.arguments[0])
|
||||
|
||||
|
||||
def do_play(self, gtp):
|
||||
pass
|
||||
if gtp.arguments[0] == 'black':
|
||||
color = goban.Goban.BLACK
|
||||
elif gtp.arguments[0] == 'white':
|
||||
color = goban.Goban.WHITE
|
||||
|
||||
row = int(gtp.arguments[1][1:])
|
||||
col = ord(gtp.arguments[1][0]) - 96
|
||||
|
||||
with self.goban_lock:
|
||||
self.goban.play_move((row,col), color)
|
||||
|
||||
|
||||
def do_genmove(self, gtp):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue