Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    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.