|
|
|
|
|
|
|
|
|
|
public class Ball3DDecision : MonoBehaviour, Decision |
|
|
|
{ |
|
|
|
public float rotationSpeed = 2f; |
|
|
|
List<float> ret = new List<float>(); |
|
|
|
if (state[2] < 0 || state[5] < 0) |
|
|
|
{ |
|
|
|
ret.Add(state[5]); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ret.Add(state[5]); |
|
|
|
} |
|
|
|
if (state[3] < 0 || state[7] < 0) |
|
|
|
{ |
|
|
|
ret.Add(-state[7]); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ret.Add(-state[7]); |
|
|
|
} |
|
|
|
return ret.ToArray(); |
|
|
|
|
|
|
|
List<float> act = new List<float>(); |
|
|
|
//state[5] is the velocity of the ball in the x orientation. We use this number to control the Platform's z axis rotation speed,
|
|
|
|
//so that the Platform is tilted in the x orientation correspondingly.
|
|
|
|
act.Add(state[5] * rotationSpeed); |
|
|
|
//state[7] is the velocity of the ball in the z orientation. We use this number to control the Platform's x axis rotation speed,
|
|
|
|
//so that the Platform is tilted in the z orientation correspondingly.
|
|
|
|
act.Add(-state[7] * rotationSpeed); |
|
|
|
return act.ToArray(); |
|
|
|
//If the vector action space type is discrete, then we don't do anything.
|
|
|
|
else |
|
|
|
{ |
|
|
|
return new float[1]{ 1f }; |
|
|
|