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. Dismiss Notice

Time interval of CollectObservations

Discussion in 'ML-Agents' started by chongxi_lai, Dec 18, 2020.

  1. chongxi_lai

    chongxi_lai

    Joined:
    Nov 22, 2020
    Posts:
    2
    I am new to Unity ML-agent. Going through a few tutorials but there is one question I don't find a clear answer yet. And I am sure this is not a new question asked here.
    What factor or parameters decides the frequency of calling CollectObservations. Is it decided by the frequency of action output generated by the Python side? or is it simply decided by the frequency of calling FixedUpdate()?

    Thanks!
     
  2. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    Collecting observations is done at every physics step or FixedUpdate() when using the CollectObservations() implementation. More explanation here - Observation & Sensors.

    Decision requests can be made manually (ad hoc) or using the
    DecisionRequestor
    component which automatically requests a decision over an interval (called a decision period). More explanation here - Actions.

    To summarize, observations are gathered every physics step, actions are returned when requested or on an interval (1-n physics steps).
     
  3. macsimilian

    macsimilian

    Joined:
    Sep 19, 2020
    Posts:
    19
    Is there a way to make the observations only collected at certain, set times? I am making a turn-based board game, and the state of the board doesn't change that often. (I have another thread asking about this here.)

    Looking at the Observation & Sensors documentation, it looks like using ISensors could work, and the VectorSensor could be used in place of CollectObservations. Then, if I understand it correctly, the Write() method is called to generate an observation. I don't understand though, from looking at the documentation, how the Write() method is called or used (code samples would be helpful).

    EDIT: Found a (potential) solution in this thread:
     
    Last edited: Aug 9, 2023