Search Unity

New Learning Environment

Discussion in 'ML-Agents' started by dani_kal, Apr 7, 2020.

  1. dani_kal

    dani_kal

    Joined:
    Mar 25, 2020
    Posts:
    52
    Hello!!

    I try to make my own environment and reinforcement learning algorithm to train agents starting from one initial position and reach a goal position while avoiding obstacles in a scene (and other agents).
    Could someone tell me..what steps I have to follow because I am a bit confused?

    1. I have to define MyArea, MyAcademy and MyAgent scripts in c-sharp?Is it right?
    2. In MyAgent.cs I have to define AgentAction() function. I want to define 8 different actions of the agent, so that means he can go, east,west,south,north,southeast, northeast, southwest and northwest. How can I do this?

    Thank you in advance!
     
  2. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
  3. dani_kal

    dani_kal

    Joined:
    Mar 25, 2020
    Posts:
    52
    Thank you for your answer!!!
    I read this manual but I still have some questions!
    In the function OnActionReceived() I have to define the available actions.
    Something like this, is right?

    switch (action)
    {
    case 0:
    // do nothing
    break;
    case 1: //go right
    new_pos = transform.position + new Vector3(1f, 0, 0f);
    break;
    case 2: //go left
    new_pos = transform.position + new Vector3(-1f, 0, 0f);
    break;
    case 3: //go up
    new_pos = transform.position + new Vector3(0f, 0, 1f);
    break;
    case 4: //go down
    new_pos = transform.position + new Vector3(0f, 0, -1f);
    break;
    }

    In this function, according to the action, a reward must be defined.
    In my project, the rewards are distributed as follows
    1.if collision between agent-obstacle == true
    reward_1 = -1
    else
    reward_1 = 0.
    2.if collision between agent-agent == true
    reward_2 = -3
    else
    reward_2 = 0.

    reward_total = reward_1 + reward_2.

    Thank you in advance!!!