Search Unity

Training to race.

Discussion in 'ML-Agents' started by Skreamz, Jan 13, 2021.

  1. Skreamz

    Skreamz

    Joined:
    Jan 8, 2015
    Posts:
    13
    Hi all, I am making a racing game and decided to use ml-agents for the ai. And they seem to learn to tracks and can navigate them better then I can . But the issue is, is that I have to train them with collision off between them, as I'm training using multiple agents. And when racing with collision on it turns into a destruction derby. If collision is on when training. They just get stuck and don't progress on their learning.

    What would be the best way around this?
    Thank you.
     
  2. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    This is a very interesting problem. I think you will need to train with self play since this is a competitive game, you should have each Agent be in a team of 1 and the trainer will train only one agent at a time and use a fixed policy on all other agents. This could slow down your training still.
    Another approach would maybe be to use curriculum learning, where the Agent starts alone on the track and new Agents are added at the Agent gets better. This way, it will start off from knowing how to drive alone before having to learn how to dodge the other karts.
    Make sure that the Agent can tell the difference between another kart and a wall (if you are using something like raycast) so the agent can figure out it can go around another kart, but not around a wall. It would also probably help if the Agent knew how fast the other karts are going (so it can avoid them better) either add this information to the raycast or use stacking of observations / memory when training and see if it helps.
     
    dhyeythumar likes this.
  3. Skreamz

    Skreamz

    Joined:
    Jan 8, 2015
    Posts:
    13
    thank you, will give it a go,
     
  4. dhyeythumar

    dhyeythumar

    Joined:
    Mar 15, 2020
    Posts:
    7
    Switching off the collision between the agents is similar to the environment having a single agent (as agents won't be interacting with each other). And if you want this behavior, then don't forget to add all the agents to the Ignore Raycast Layer.
    But if you are looking for competition between agents then you should try the methods given by @vincentpierre.