def _describe_comment(move): comment = move.get_comment() if not comment or comment is None or len(comment) <= 0: return '' return ' Also said "%s"' % Protocol.sanitize_comment(comment)
def _parse_input(input_): input_ = input_.replace(' ', '').lower() if Human._starts_with(input_, 'q'): raise Exception('Exiting') move = Protocol.parse_move(input_) if not GameScoringRules.is_move_legal(move): raise ProtocolException('Can make max 3 things at a time!') return move
def run(self, fighter): protocol = Protocol(self._in_stream, self._out_stream) protocol.handshake() resp = ServerResponse() while not self._cancel_flag: move = fighter.make_next_move(resp.move, resp.score1, resp.score2) protocol.send_request(move) resp = protocol.read_response()