def reorganize_pettingzoo(trajectories):
    ''' Reorganize the trajectory to make it RL friendly

    Args:
        trajectory (list): A list of trajectories

    Returns:
        (list): A new trajectories that can be fed into RL algorithms.

    '''
    new_trajectories = defaultdict(list)
    for agent_name, trajectory in trajectories.items():
        for i in range(0, len(trajectory)-2, 2):
            transition = [
                trajectory[i][0], # obs,
                trajectory[i+1], # action
                trajectory[i+2][1], # reward
                trajectory[i+2][0], # next_obs
                trajectory[i+2][2], # done
            ]
            new_trajectories[agent_name].append(transition)
    return new_trajectories
 Reorganize the trajectory to make it RL friendly

    Args:
        trajectory (list): A list of trajectories

    Returns:
        (list): A new trajectories that can be fed into RL algorithms.

    
rlcard/utils/pettingzoo_utils.py