ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

ML agents with coroutine

Open billluky opened this issue 8 years ago • 3 comments

In my learning environment, my agent is a sphere that can expand and shrink.

To implement the effect of gradually expanding and shrinking, I used a coroutine, which means that when an action was taken, the coroutine with a for loop will make the sphere expand or shrink slowly.

However, in the process of training, the development console showed:

coroutine --> IsInList()

UnityEngine.Coroutine:Finalize()

this is the IEnumerator of the function:

IEnumerator ExpandOrShrink(Transform sphere, float minScale, float maxScale, float scaleFactor, int exOrsh)
    {
        if (exOrsh == 1)//1 for expand,-1 for shrink
        {
            changingTimes = (maxScale - sphere.localScale.x) / scaleFactor;//times of expanding
        }
        if (exOrsh == -1)
        {
            changingTimes = (sphere.localScale.x - minScale) / scaleFactor;//times of shrinking
        }
        for (int i = 0; i < changingTimes; i++)
        {
            sphereScale += exOrsh * scaleFactor;
            sphereScale = Mathf.Clamp(sphereScale, minScale, maxScale);
            sphere.localScale = new Vector3(sphereScale, sphereScale, sphereScale);
            yield return new WaitForFixedUpdate();
        }
    }

(Each actions (2 discrete actions) will stop all coroutine and start the coroutine.) Also, the training didn't work well, all of std of rewards are 0.000, which was mentioned my another issue.

billluky avatar May 28 '18 01:05 billluky

Hey @billluky, I see we haven't had any responses in this thread for a while. Do you still need help with this issue?

eshvk avatar Jul 17 '18 20:07 eshvk

Hi All,

I am closing this thread due to inactivity, but feel free to re-open it if you desire.

awjuliani avatar Sep 06 '18 19:09 awjuliani

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 03 '20 04:01 lock[bot]