def reset(self):
        if self._channel is not None:
            # Client surrenders in the current game and starts next one.

            self._channel.close()
            self._channel = None

        # Get game server address and side id from master.
        start_game_request = master_pb2.StartGameRequest(
            game_version=config.game_version,
            username=self._username,
            token=self._token,
            model_name=self._model_name,
            include_rendering=self._include_rendering)
        response = self._reset_with_retries(start_game_request)
        self._game_id = response.game_id
        self._channel = utils.get_grpc_channel(response.game_server_address)
        grpc.channel_ready_future(self._channel).result()
        get_env_result_request = game_server_pb2.GetEnvResultRequest(
            game_version=config.game_version,
            game_id=self._game_id,
            username=self._username,
            token=self._token,
            model_name=self._model_name)
        return self._get_env_result(get_env_result_request, 'GetEnvResult')[0]
 def _update_master(self):
   while True:
     try:
       master_address = utils.get_master_address(self._track)
       logging.info('Connecting to %s', master_address)
       self._master_channel = utils.get_grpc_channel(master_address)
       grpc.channel_ready_future(self._master_channel).result(timeout=10)
       break
     except grpc.FutureTimeoutError:
       logging.info('Failed to connect to master')
     except BaseException as e:
       logging.info('Error %s, sleeping 10 secs', e)
       time.sleep(10)
   logging.info('Connection successful')