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

Question How to feed a 2D integer array into observations?

Discussion in 'ML-Agents' started by Alca-Lynn, Jul 1, 2022.

  1. Alca-Lynn

    Alca-Lynn

    Joined:
    Sep 8, 2020
    Posts:
    5
    Hi, friends!

    I'm haven't write down the codes now and come to ask the question beforehand. Hope you understand.

    I'm creating a simulation which involves 5 stations and some obstacles moving around blocking them from connected. The agent's goal is to make sure all 5 stations stay connected, in other words, there should not have station(s) is seperated. Also, a station can have at most 2 connections, so there shouldn't have circles.
    upload_2022-7-1_17-47-59.png
    So i am thinking using a 2D 5x5 integer array:
    int[5,5] ConnectionMap
    to store the connections. 0 - available, 1 - connected, 2 - blocked. And im not using camara observation.

    Here is my problem: how can I or can I send this 2D array into observations? I'm using ml-agent 19 and I don't remember there is a way that you can send a multi-dimension array into observations, correct me if there is any.

    And also, if you have any ideas on how can i optimize the solution above, that would be great of help!
     
  2. Zibelas

    Zibelas

    Joined:
    Aug 1, 2017
    Posts:
    6
    a 5x5 array is the same as a single one that has 25 entries. You can as well just loop over your 5x5 array and add each entry as an observation.
     
    Alca-Lynn likes this.