26 lines
621 B
C#
26 lines
621 B
C#
namespace GameCli;
|
|
|
|
/// <summary>
|
|
/// Builds the 7-dim observation vector fed to PPO:
|
|
/// [dx, dy, vx, vy, sin(angle), cos(angle), angular_velocity]
|
|
/// Angle is encoded as sin/cos to avoid the discontinuity at ±π.
|
|
/// </summary>
|
|
public static class Observation
|
|
{
|
|
public const int Dim = 7;
|
|
|
|
public static float[] Build(ShipState s, (float X, float Y) target)
|
|
{
|
|
return new float[Dim]
|
|
{
|
|
target.X - s.X,
|
|
target.Y - s.Y,
|
|
s.VX,
|
|
s.VY,
|
|
MathF.Sin(s.Angle),
|
|
MathF.Cos(s.Angle),
|
|
s.AngularVelocity,
|
|
};
|
|
}
|
|
}
|