Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question [ML Agents api] How to access to the values of the action vector?

Discussion in 'ML-Agents' started by pradajohn, Jan 17, 2023.

  1. pradajohn

    pradajohn

    Joined:
    Jan 19, 2017
    Posts:
    10
    Hi.
    I am trying to get the values of the action.

    env.reset()
    decision_steps, terminal_steps = env.get_steps(behavior_name)
    action = spec.action_spec.random_action(len(decision_steps))
    print("Action: {}".format(action))
    # Set the actions
    env.set_actions(behavior_name, action_tuple)
    # Move the simulation forward
    env.step()


    the action vector is a random array of size = 3

    the print output is in this way
    Action: <mlagents_envs.base_env.ActionTuple object at 0x000001E19B827070>


    I want to get the print output this way.
    Action: [-0.86223789 -0.93306082  0.93841699]
    (These are random numbers)

    Any suggestions?
    Thank you
     
  2. pradajohn

    pradajohn

    Joined:
    Jan 19, 2017
    Posts:
    10
    I found the solution. i just needed to put the action like this
    print("Action: {}".format(action.continous[0]))
     
    hughperkins likes this.