|
|
|
|
|
|
|
|
// to be implemented by the developer |
|
|
// to be implemented by the developer |
|
|
public override void AgentAction(float[] vectorAction, string textAction) |
|
|
public override void AgentAction(float[] vectorAction, string textAction) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
//print("Action before FloorToInt: " + vectorAction[0]); |
|
|
int action = Mathf.FloorToInt(vectorAction[0]); |
|
|
int action = Mathf.FloorToInt(vectorAction[0]); |
|
|
Point centerOfGravity = onRenderImageTest.CenterOfGravity; |
|
|
Point centerOfGravity = onRenderImageTest.CenterOfGravity; |
|
|
Vector3 targetPos = transform.position; |
|
|
|
|
|
|
|
|
//Vector3 targetPos = transform.position; |
|
|
|
|
|
|
|
|
|
|
|
//print("Action after FloorToInt: " + action); |
|
|
|
|
|
|
|
|
AddReward(-0.01f); |
|
|
AddReward(-0.01f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movement.Turn(-1); |
|
|
movement.Turn(-1); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
movement.Move(0); |
|
|
|
|
|
|
|
|
//movement.Move(0); |
|
|
throw new ArgumentException("Invalid action value. Stop movement."); |
|
|
throw new ArgumentException("Invalid action value. Stop movement."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If centerOfGravity lies near to the center of the image horizontally |
|
|
// If centerOfGravity lies near to the center of the image horizontally |
|
|
if (centerOfGravity.X > renderCamera.targetTexture.width / 2 - nearAreaLimit && centerOfGravity.X < renderCamera.targetTexture.width / 2 + nearAreaLimit) |
|
|
if (centerOfGravity.X > renderCamera.targetTexture.width / 2 - nearAreaLimit && centerOfGravity.X < renderCamera.targetTexture.width / 2 + nearAreaLimit) |
|
|
{ |
|
|
{ |
|
|
Done(); |
|
|
|
|
|
SetReward(1); |
|
|
SetReward(1); |
|
|
print("Reward: +1"); |
|
|
print("Reward: +1"); |
|
|
} |
|
|
} |
|
|
else if (centerOfGravity.X > renderCamera.targetTexture.width / 2 - farAreaLimit && centerOfGravity.X < renderCamera.targetTexture.width / 2 + farAreaLimit) |
|
|
else if (centerOfGravity.X > renderCamera.targetTexture.width / 2 - farAreaLimit && centerOfGravity.X < renderCamera.targetTexture.width / 2 + farAreaLimit) |
|
|
{ |
|
|
{ |
|
|
Done(); |
|
|
|
|
|
SetReward(-1); |
|
|
|
|
|
print("Reward: -1"); |
|
|
|
|
|
|
|
|
SetReward(-0.7f); |
|
|
|
|
|
print("Reward: -0.7"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Done(); |
|
|
|
|
|
SetReward(-2); |
|
|
|
|
|
print("Reward: -2"); |
|
|
|
|
|
|
|
|
SetReward(-1); |
|
|
|
|
|
print("Reward: -1"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|