def advance_time_step(model, env, brain_name, states, actions, rewards, next_states, dones):
    """Advances the agents' model and the environment to the next time step, passing data
       between the two as needed.

       Params
           model (Maddpg):         the MADDPG model that manages all agents
           env (UnityEnvironment): the environment object in which all action occurs
           brain_name (string):    an index into the Unity data structure for this environment
           states (ndarray):       array of current states of all agents and environment [n, x]
           actions (ndarray):      array of actions by all agents [n, x]
           rewards (list):         list of rewards from all agents [n]
           next_states (ndarray):  array of next states (after action applied) [n, x]
           dones (list):           list of done flags (int, 1=done, 0=in work) [n]
       where, in each param, n is the number of agents and x is the number of items per agent.

       Returns: tuple of (s, a, r, s', done) values
    """

    # Predict the best actions for the current state and store them in a single ndarray
    actions = model.act(states) #returns ndarray, one row for each agent

    # get the new state & reward based on this action
    env_info = env.step(actions)[brain_name]
    next_states = env_info.vector_observations #returns ndarray, one row for each agent
    rewards = env_info.rewards #returns list of floats, one for each agent
    dones = env_info.local_done #returns list of bools, one for each agent

    # update the agents with this new info
    model.step(states, actions, rewards, next_states, dones) 

    # roll over new state
    states = next_states

    return (states, actions, rewards, next_states, dones)