Search Unity

Issues of multi brains in self-play

Discussion in 'ML-Agents' started by YunaoShen, Mar 28, 2020.

  1. YunaoShen

    YunaoShen

    Joined:
    Sep 9, 2019
    Posts:
    10
    Did current version of self-play supports multi brain training? In my project I have four roules: striker, midfielder,back and goalie in a soccer game, but I failed to train with self-play. When I try only one brain at the same time the error didn't show up any more.

    Traceback:
    Traceback (most recent call last):
    File "/home/seonghyeon/.conda/envs/mlagents2/bin/mlagents-learn", line 8, in <module>
    sys.exit(main())
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/learn.py", line 495, in main
    run_cli(parse_command_line())
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/learn.py", line 491, in run_cli
    run_training(run_seed, options)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/learn.py", line 329, in run_training
    tc.start_learning(env_manager)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents_envs/timers.py", line 258, in wrapped
    return func(*args, **kwargs)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/trainer_controller.py", line 207, in start_learning
    n_steps = self.advance(env_manager)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents_envs/timers.py", line 258, in wrapped
    return func(*args, **kwargs)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/trainer_controller.py", line 267, in advance
    num_steps = env.advance()
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/env_manager.py", line 91, in advance
    num_step_infos = self._process_step_infos(new_step_infos)
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/env_manager.py", line 108, in _process_step_infos
    name_behavior_id, ActionInfo.empty()
    File "/home/seonghyeon/.conda/envs/mlagents2/lib/python3.7/site-packages/mlagents/trainers/agent_processor.py", line 101, in add_experiences
    action = stored_take_action_outputs["action"][idx]
    IndexError: index 14 is out of bounds for axis 0 with size 14
     
  2. LexVolkov

    LexVolkov

    Joined:
    Sep 14, 2014
    Posts:
    62
    works for me for two brains. check the code.
     
  3. YunaoShen

    YunaoShen

    Joined:
    Sep 9, 2019
    Posts:
    10
    If I'm not wrong there is no need to edit scripts to enable self-play. The project could work well in one brain self play and non self play. So there should be no problem in codes. Maybe it's because I'm using continuous actions? According to traceback it's actions that encouter errors.
     
  4. andrewcoh_unity

    andrewcoh_unity

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    162
    The current implementation of self-play only supports teams with the same brains. I'd need more information to help understand the stack trace. Are you modifying the Soccer example environment to add multiple agents with different observation/action spaces?
     
  5. YunaoShen

    YunaoShen

    Joined:
    Sep 9, 2019
    Posts:
    10
    The problem is that agents sometimes get no raycasts observations cuz higher altitude than borders. So I think the error has nothing to do with self-play implementation. But I do found that self-play didn't work well with multi brains.
     
  6. M2jorTom

    M2jorTom

    Joined:
    May 7, 2019
    Posts:
    4
    Hi, I found a way to avoid this problem.
    Go to the root directory of the project(where you can see "ml-agents" folder),open the command line and execute "pip3 install -e ./ml-agents-envs" and "pip3 install -e ./ml-agents".Train again,and the training program will not crash.:)