Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Communication Error: Communicator has exited?

Discussion in 'ML-Agents' started by Vanguardean, Apr 19, 2023.

  1. Vanguardean

    Vanguardean

    Joined:
    Feb 6, 2023
    Posts:
    2
    Hi there,

    I am using unity mlagents 2.3.0-exp3 and python 0.30. I am getting an error or crash (Depending on how you see it) when i launch my environment via python/yaml file (jupiter notebook). It works fine. I have written code in unity that on Update(), the method looks for the keyboard button that will quit the application (build). When this is pressed without the communication with python/yaml, it works fine and the window/build closes without a crash or freeze. However, when using python and yaml config file and then pressing the keyboard button i set up for quitting the application, the build/window freezes and it takes a very long time for it to close/terminate.

    I am assuming that there is a socket/communication that is open between python/yaml file and unity when the application quits which causes it to crash/freeze. How can i fix this problem?

    Below is the config file with error thrown:

    Code (CSharp):
    1. !ArenaConfig
    2. arenas:
    3.   0: !Arena
    4.     pass_mark: 0
    5.     t: 250
    6.     items:
    7.     - !Item
    8.       name: Agent
    9.       positions:
    10.       - !Vector3 {x: 10, y: 0, z: 20}
    11.       rotations: [90]
    12.     - !Item
    13.       name: SignPosterboard
    14.       positions:
    15.       - !Vector3 {x: 20, y: 0, z: 8}
    16.       symbolNames:
    17.       - "left-arrow"
    18.     - !Item
    19.       name: ShrinkGoal
    20.       positions:
    21.       - !Vector3 {x: 20, y: 0, z: 14}
    22.       sizes:
    23.       - !Vector3 {x: 0.1, y: 0.1, z: 0.1}
    24.       symbolNames:
    25.       - "left-arrow"
    26.       initialValues: [2.5]
    27.       finalValues: [1.5]
    28.       delays: [400]
    29.       changeRates: [-0.2]
    30.     - !Item
    31.       name: DecayGoal
    32.       positions:
    33.       - !Vector3 {x: 20, y: 0, z: 20}
    34.       initialValues: [4]
    35.       finalValues: [3]
    36.       delays: [250]
    37.       changeRates: [-0.003]
    38.     - !Item
    39.       name: AntiDecayGoal
    40.       positions:
    41.       - !Vector3 {x: 20, y: 0, z: 26}
    42.       sizes:
    43.       - !Vector3 {x: 0.1, y: 0.1, z: 0.1}
    44.       initialValues: [1]
    45.       finalValues: [1.5]
    46.       delays: [300]
    47.       changeRates: [-0.007]
    48.     - !Item
    49.       name: GrowGoal
    50.       positions:
    51.       - !Vector3 {x: 20, y: 0, z: 32}
    52.       initialValues: [1]
    53.       finalValues: [3.5]
    54.       delays: [100]
    55.       changeRates: [0.01]
    56.     - !Item
    57.       name: SpawnerTree
    58.       positions:
    59.       - !Vector3 {x: 30, y: 0, z: 30}
    60.       ripenTimes: [3]
    61.       timesBetweenSpawns: [0.5]
    62.       spawnCounts: [50]
    63.       finalValues: [1]
    64.     - !Item
    65.       name: SpawnerDispenser
    66.       positions:
    67.       - !Vector3 {x: 30, y: 0, z: 10}
    68.       spawnCounts: [-1]
    69.       timesBetweenDoorOpens: [-1]
    70.     - !Item
    71.       name: SpawnerContainer
    72.       positions:
    73.       - !Vector3 {x: 30, y: 0, z: 20}
    74.       spawnCounts: [1]
    75.       doorDelays: [20]
    76.       timesBetweenDoorOpens: [1]
    77. initializing AAI environment
    78. Traceback (most recent call last):
    79.   File "c:\Users\ia424\Desktop\alternativePythonExecution.py", line 20, in <module>
    80.     environment = AnimalAIEnvironment(
    81.   File "c:\users\ia424\desktop\animal-ai\animalai\animalai\envs\environment.py", line 98, in __init__
    82.     self.reset(arenas_configurations)
    83.   File "c:\users\ia424\desktop\animal-ai\animalai\animalai\envs\environment.py", line 166, in reset
    84.     super().reset()
    85.   File "C:\Users\ia424\anaconda3\envs\cfi\lib\site-packages\mlagents_envs\environment.py", line 322, in reset
    86.     raise UnityCommunicatorStoppedException("Communicator has exited.")
    87. mlagents_envs.exception.UnityCommunicatorStoppedException: Communicator has exited.
    Thanks for looking!