public NPCAction() { s = MatrixXd.Zero(S, N); a = MatrixXd.Zero(A, N); s_ = MatrixXd.Zero(S, N); a_ = MatrixXd.Zero(A, N); r = RowVectorXd.Zero(N); }
private void Update() { Owner.Get <AircraftComponent>().Accelerate(); //var destination = Transform.Position + new Vector3(0, 1, 0); //Owner.Get<AIComponent>().AutoPilot(destination); var curvedSurface = (Entity.Find("ground").Get <CollisionComponent>().Shape as CurvedSurface); float distance = 0; { Point ray = new Point() { Matrix = new Matrix4x3().Identity().Translate(Transform.Position), Velocity = Transform.Forward * 1000 }; var point = curvedSurface.Collide(ray); if (float.IsNaN(point.X)) { distance = 1; } else { distance = (Transform.Position - point).Magnitude / 1000; } } float height = curvedSurface.ComputeHeight(Transform.Position) / 500; float upwardY = Transform.Upward.Y; if (frame % 10 == 0) { X[0, N] = distance; X[1, N] = height; X[2, N] = upwardY; D[0, N] = distance; N++; } assert(N < 8192); MatrixXd x = MatrixXd.Zero(3, 1); x[0, 0] = distance; x[1, 0] = height; X[2, N] = upwardY; this.RiskPredict = CollisionPredictionNetwork.Forward(x)[0, 0]; this.Distance = distance; this.Height = height; this.UpwardY = upwardY; }