Search Unity

Question Need help with ML Agent avoid obstacle

Discussion in 'ML-Agents' started by chauviloc, Nov 28, 2021.

  1. chauviloc

    chauviloc

    Joined:
    May 18, 2015
    Posts:
    2
    Hi everyone!

    I have problem with my agent, I tried to train them to avoid obstacle and collect the ball. I already train with 50,000,000 max step but it still not work.
    Here is my logic to train agent:
    - OnEpisodeBegin: I just reset agent's position.
    - CollectObservations:
    + Collect ball postion.
    + Collect agent position.
    + Collect direction from agent to ball.
    + Collect distance from agent to ball.
    + Collect environment info via RayPerceptionSensor3D component.
    - OnActionReceived:
    + Just move and rotate agent with direction get from actions.ContinuousAction.
    - Reward:
    + +5 when agent got ball.
    + -2 when agent hit the wall or obstacle.
    After agent get ball or hit wall I also call EndEpisode.

    My config:

    behaviors:
    CharAgent:
    trainer_type: ppo
    max_steps: 50000000
    time_horizon: 64
    summary_freq: 10000
    keep_checkpoints: 5
    hyperparameters:
    batch_size: 512
    buffer_size: 2048
    learning_rate: 0.0003
    beta: 0.05
    epsilon: 0.2
    lambd: 0.99
    num_epoch: 3
    learning_rate_schedule: linear
    network_settings:
    normalize: false
    hidden_units: 128
    num_layers: 2
    vis_encode_type: simple
    reward_signals:
    extrinsic:
    gamma: 0.99
    strength: 1.0

    **** As I think right now is the agent auto learn to go around the obstacle or did I missing something to let the agent know how to move around the obstacle?

    Result after train: Agent still can't move around the obstacle to get the ball.
    The image below show the scene I setup to train agent.


    Anyone have idea about my problem, I just play with MLAgent for a week.
    Please give me advise.
    Thank you.
     
    Ordpers likes this.