|
|
@@ -51,10 +51,12 @@ public class CozmoAgent : Agent |
|
|
|
// to be implemented by the developer |
|
|
|
public override void AgentAction(float[] vectorAction, string textAction) |
|
|
|
{ |
|
|
|
|
|
|
|
//print("Action before FloorToInt: " + vectorAction[0]); |
|
|
|
int action = Mathf.FloorToInt(vectorAction[0]); |
|
|
|
Point centerOfGravity = onRenderImageTest.CenterOfGravity; |
|
|
|
Vector3 targetPos = transform.position; |
|
|
|
//Vector3 targetPos = transform.position; |
|
|
|
|
|
|
|
//print("Action after FloorToInt: " + action); |
|
|
|
|
|
|
|
AddReward(-0.01f); |
|
|
|
|
|
|
@@ -73,7 +75,7 @@ public class CozmoAgent : Agent |
|
|
|
movement.Turn(-1); |
|
|
|
break; |
|
|
|
default: |
|
|
|
movement.Move(0); |
|
|
|
//movement.Move(0); |
|
|
|
throw new ArgumentException("Invalid action value. Stop movement."); |
|
|
|
} |
|
|
|
|
|
|
@@ -87,21 +89,18 @@ public class CozmoAgent : Agent |
|
|
|
// 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) |
|
|
|
{ |
|
|
|
Done(); |
|
|
|
SetReward(1); |
|
|
|
print("Reward: +1"); |
|
|
|
} |
|
|
|
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 |
|
|
|
{ |
|
|
|
Done(); |
|
|
|
SetReward(-2); |
|
|
|
print("Reward: -2"); |
|
|
|
SetReward(-1); |
|
|
|
print("Reward: -1"); |
|
|
|
} |
|
|
|
} |
|
|
|
|