def build_algorithm(trainer):
    """ Builds the RL algorithm
        :param trainer: A reinforcement learning trainer instance.
        :type trainer: diplomacy_research.models.training.reinforcement.trainer.ReinforcementTrainer
    """
    if not trainer.queue_dataset or not trainer.model:
        raise RuntimeError(
            'You must build the model and the dataset before building the RL algorithm'
            )
    trainer.algorithm = trainer.algorithm_constructor(trainer.queue_dataset,
        trainer.model, trainer.hparams)
