From 2a09b6f71f92ac8ccd792877f93c603594ef6b92 Mon Sep 17 00:00:00 2001 From: Andrés Ambrois Date: Sat, 16 Aug 2008 11:20:06 +0000 Subject: gtp.py: Delegate color handling to the caller --- diff --git a/gtp.py b/gtp.py index 98a500a..22bc442 100644 --- a/gtp.py +++ b/gtp.py @@ -34,9 +34,8 @@ def search_for_gnugo(): class gnugo: ''' A wrapper for talking to gnugo over GTP ''' - def __init__(self, boardsize=19, color='black', handicap=0, komi=5.5, level=3): + def __init__(self, boardsize=19, handicap=0, komi=5.5, level=3): ''' Start the gnugo subprocess ''' - self.color = color try: self.gnugo = Popen(['gnugo', '--mode', 'gtp', '--boardsize', str(boardsize), '--handicap', str(handicap), '--komi', str(komi), '--level', str(level) ], @@ -57,8 +56,8 @@ class gnugo: def _coords_to_xy(self, coords): return int(dict(zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ', range(0, 26)))[coords[0]]), int(coords[1:]) - def make_play(self, x, y): - self.stdin.write('play %s %s\n' % (self.color, self._xy_to_coords(x, y))) + def make_play(self, color, x, y): + self.stdin.write('play %s %s\n' % (color, self._xy_to_coords(x, y))) self.stdin.flush() output = self.stdout.readline() self.stdout.readline() -- cgit v0.9.1