ML agents with coroutine
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.
Hey @billluky, I see we haven't had any responses in this thread for a while. Do you still need help with this issue?
Hi All,
I am closing this thread due to inactivity, but feel free to re-open it if you desire.
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.