(network, room=False, agent=False, ui_en=False)
Description: This facilitates playing a match  
    Arguments:  
    * network: An `network`(pommerman.network.ion_client.network) object  
    * room: If String, The room to be created/joined. If False, the public \
room will be joined  
    * agent: The class of the agent should be a derivative of BaseAgent  
    * ui_en: If the UI is enabled or disabled (This also controls if exception \
are raised or not)
    Returns: Array [reward, match_id]
Description: This facilitates playing a match  
    Arguments:  
    * network: An `network`(pommerman.network.ion_client.network) object  
    * room: If String, The room to be created/joined. If False, the public \
room will be joined  
    * agent: The class of the agent should be a derivative of BaseAgent  
    * ui_en: If the UI is enabled or disabled (This also controls if exception \
are raised or not)
    Returns: Array [reward, match_id]
Description : This facilitates playing a match Arguments : * network : An network ( pommerman . network . ion_client . network ) object * room : If String The room to be created / joined . If False the public \ room will be joined * agent : The class of the agent should be a derivative of BaseAgent * ui_en : If the UI is enabled or disabled ( This also controls if exception \ are raised or not ) Returns : Array [ reward match_id ]
def match(network, room=False, agent=False, ui_en=False):
    """Description: This facilitates playing a match  
    Arguments:  
    * network: An `network`(pommerman.network.ion_client.network) object  
    * room: If String, The room to be created/joined. If False, the public \
room will be joined  
    * agent: The class of the agent should be a derivative of BaseAgent  
    * ui_en: If the UI is enabled or disabled (This also controls if exception \
are raised or not)
    Returns: Array [reward, match_id]"""
    agent = agent()
    if ui_en:
        ui.info(ui.yellow, constants.Strings.server_comm.value)
    try:
        network.join_list(room)
    except Exception as e:
        if ui_en:
            ui.fatal(e)
        raise e
    if ui_en:
        ui.info(constants.Strings.match_variant.value, ui.yellow, network.mode)
        ui.info(ui.yellow, constants.Strings.match_wait.value)
    try:
        network.wait_match()
    except Exception as e:
        if ui_en:
            ui.fatal(e)
        raise e
    if ui_en:
        ui.info(constants.Strings.match_run.value, "#" + network.match_id)
    for mode in pommerman.constants.GameType:
        if mode.name in network.mode:
            agent.init_agent(
                id=0, game_type=mode
            )  # We always use ID as 0 as the server doesn't return it
    while True:
        try:
            match_obj = network.match_get()
        except Exception as e:
            if ui_en:
                ui.fatal(e)
            raise e
        # match_obj[0] is the intent: 0 = OBS, 1 = Agent Dead, 2 = Match End
        if match_obj[0] is 0:
            action = agent.act(match_obj[1], gym.spaces.Discrete(6))
            try:
                network.send_move(action, match_obj[2])
            except Exception as e:
                if ui_en:
                    ui.fatal(e)
                raise e
        elif match_obj[0] is 2:
            agent.episode_end(reward=match_obj[1])
            if ui_en:
                if match_obj[1] == 1:
                    ui.info(constants.Strings.match_won.value)
                if match_obj[1] == -1:
                    ui.info(constants.Strings.match_loss_draw.value)
                ui.info(
                    constants.Strings.match_agent.value,
                    ui.yellow,
                    pommerman.constants.Item(match_obj[2]).name,
                )
            else:
                return [match_obj[1], network.match_id]
            break
    ui.info(constants.Strings.match_replay.value, ui.yellow, network.match_id)
    if ui.ask_yes_no(constants.Strings.match_ask_replay.value):
        replay(network, network.match_id)
    else:
        intent(network)
def match ( network , room = False , agent = False , ui_en = False ) : agent = agent ( ) if ui_en : ui . info ( ui . yellow , constants . Strings . server_comm . value ) try : network . join_list ( room ) except Exception as e : if ui_en : ui . fatal ( e ) raise e if ui_en : ui . info ( constants . Strings . match_variant . value , ui . yellow , network . mode ) ui . info ( ui . yellow , constants . Strings . match_wait . value ) try : network . wait_match ( ) except Exception as e : if ui_en : ui . fatal ( e ) raise e if ui_en : ui . info ( constants . Strings . match_run . value , "#" + network . match_id ) for mode in pommerman . constants . GameType : if mode . name in network . mode : agent . init_agent ( id = 0 , game_type = mode ) # We always use ID as 0 as the server doesn't return it while True : try : match_obj = network . match_get ( ) except Exception as e : if ui_en : ui . fatal ( e ) raise e # match_obj[0] is the intent: 0 = OBS, 1 = Agent Dead, 2 = Match End if match_obj [ 0 ] is 0 : action = agent . act ( match_obj [ 1 ] , gym . spaces . Discrete ( 6 ) ) try : network . send_move ( action , match_obj [ 2 ] ) except Exception as e : if ui_en : ui . fatal ( e ) raise e elif match_obj [ 0 ] is 2 : agent . episode_end ( reward = match_obj [ 1 ] ) if ui_en : if match_obj [ 1 ] == 1 : ui . info ( constants . Strings . match_won . value ) if match_obj [ 1 ] == - 1 : ui . info ( constants . Strings . match_loss_draw . value ) ui . info ( constants . Strings . match_agent . value , ui . yellow , pommerman . constants . Item ( match_obj [ 2 ] ) . name , ) else : return [ match_obj [ 1 ] , network . match_id ] break ui . info ( constants . Strings . match_replay . value , ui . yellow , network . match_id ) if ui . ask_yes_no ( constants . Strings . match_ask_replay . value ) : replay ( network , network . match_id ) else : intent ( network )