def _set_handicap(self): if self._handicap == 0: self._command_and_response("komi 7.5\n") self._sgf.append("KM[7.5]\n") else: stones = self._command_and_response("fixed_handicap {}\n".format(self._handicap)) sgf_handicap = "HA[{}]AB".format(self._handicap) for pos in stones.split(" "): move = Move(gtp_position_to_coords(pos)) self._game_state = self._game_state.apply_move(move) sgf_handicap = sgf_handicap + "[" + self._sgf.coordinates(move) + "]" self._sgf.append(sgf_handicap + "\n")
def _play_their_move(self): their_name = self._their_color.name their_letter = their_name[0].upper() pos = self._command_and_response("genmove {}\n".format(their_name)) if pos.lower() == 'resign': self._game_state = self._game_state.apply_move(Move.resign()) self._stopped = True elif pos.lower() == 'pass': self._game_state = self._game_state.apply_move(Move.pass_turn()) self._sgf.append(";{}[]\n".format(their_letter)) if self._game_state.last_move.is_pass: self._stopped = True else: move = Move(gtp_position_to_coords(pos)) self._game_state = self._game_state.apply_move(move) self._sgf.append(";{}[{}]\n".format(their_letter, self._sgf.coordinates(move)))