Search Unity

Request multiple decisions in loop

Discussion in 'ML-Agents' started by Whitecold, Mar 18, 2021.

  1. Whitecold

    Whitecold

    Joined:
    Jan 29, 2015
    Posts:
    23
    I trained my model and it works step by step, but now I would like to predict multiple steps at once in a loop to display the path the agent wants to take:

    Code (CSharp):
    1. for (int i = 0; i < maxSteps; i++) {
    2.             RequestDecision();
    3.             moveList.Add(new System.Tuple<Vector2, Vector2>(currentPosition, currentDirection));
    4.  
    5.         }
    The problem is that the Sensor state doesn't update. How can I feed the updated sensor data on each subsequent call to RequestDecision()?
     
  2. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Hi @Whitecold,
    Unfortunately, RequestDecision will only flag your agent to send its observations and get an Action later in the frame. We are talking about making this functionality more customizable and any feedback you have around this issue will definitely impact our decisions.

    Could you expand upon the environment you are working on to give us a better idea behind the motivation of wanting this feature?

    Also, if you feel so inclined, please file a feature request on our github page.
     
  3. Whitecold

    Whitecold

    Joined:
    Jan 29, 2015
    Posts:
    23
    I would like to show a prediction of a selected agent's action, the path it is going to take, and also how long it will need.
    This means I have to get a decision, update the position and request a new one until I am at the target.

    This means that for that particular agent, I need to several times update the sensor values, (only a few vectors) and get a new decision in the same frame.
     
  4. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    Could you time-slice the projection over several frames? This would give you what you want, but your code will be a bit more complex.
     
  5. Whitecold

    Whitecold

    Joined:
    Jan 29, 2015
    Posts:
    23
    Not really. I wanted to show the path when players plan movement orders. So the target is effectively the mouse cursor, which changes position every frame.
     
  6. christophergoy

    christophergoy

    Joined:
    Sep 16, 2015
    Posts:
    735
    You could still time slice the path, it would just look animated when you moved the mouse.

    Is the mouse moving over a navmesh or a grid of some sort? In this sense, you'd only need to update if the mouse moved to a different navmesh node or grid cell.