public LanderSimulator(LanderSimulator _other) { m_startX = _other.m_startX; m_startY = _other.m_startY; m_tangentStartX = _other.m_tangentStartX; m_tangentStartY = _other.m_tangentStartY; m_targetX = _other.m_targetX; m_targetY = _other.m_targetY; m_tangentTargetX = _other.m_tangentTargetX; m_tangentTargetY = _other.m_tangentTargetY; m_peakTime = _other.m_peakTime; m_curveLength = _other.m_curveLength; }
public static void Main(string[] args) { #endif string[] inputs; string line = Console.ReadLine(); Console.Error.WriteLine(line); ms_simulation = new LanderSimulator(line); // game loop while (true) { line = Console.ReadLine(); //Console.Error.WriteLine( line ); inputs = line.Split(' '); int X = int.Parse(inputs[0]); int Y = int.Parse(inputs[1]); int HS = int.Parse(inputs[2]); // the horizontal speed (in m/s), can be negative. int VS = int.Parse(inputs[3]); // the vertical speed (in m/s), can be negative. int F = int.Parse(inputs[4]); // the quantity of remaining fuel in liters. int R = int.Parse(inputs[5]); // the rotation angle in degrees (-90 to 90). int P = int.Parse(inputs[6]); // the thrust power (0 to 4). // float CurrentAngle = (float) Math.PI * R / 180.0f; // float CurrentAx = (float) Math.Sin( -CurrentAngle ); // Horizontal acceleration // float CurrentAy = (float) Math.Cos( CurrentAngle ); // Vertical acceleration // // float CurrentVx = HS; // float CurrentVy = VS; // // float TimeAhead = 20.0f; // Plan 10s ahead // float ProjectedX = X + TimeAhead * (CurrentVx + 0.5f * TimeAhead * CurrentAx); // float ProjectedY = Y + TimeAhead * (CurrentVy + 0.5f * TimeAhead * CurrentAy); // // Console.Error.WriteLine( "Ax = " + CurrentAx + " - Ay = " + CurrentAy ); // Console.Error.WriteLine( "Vx = " + CurrentVx + " - Vy = " + CurrentVy ); // Console.Error.WriteLine( "ProjX = " + ProjectedX + " - ProjY = " + ProjectedY ); // // // Course correct // float ErrorX = ProjectedX - TargetX; // float ErrorY = Math.Max( 0.0f, ProjectedY - TargetY ); // // // Attenuate angle when close to target // const float DampingStartDistance = 500.0f; // Start damping angle at this distance // const float DampingEndDistance = 100.0f; // Start damping angle at this distance // // float Dx = X - TargetX; // float Dy = Y - TargetY; // float DistanceFromTarget = (float) Math.Sqrt( Dx*Dx + Dy*Dy ); // float AngularDamping = Math.Min( 1.0f, Math.Max( 0.0f, (DistanceFromTarget - DampingEndDistance) / (DampingStartDistance - DampingEndDistance) ) ); // AngularDamping = (float) Math.Pow( AngularDamping, 4.0 ); // // Console.Error.WriteLine( "DistanceFromTarget = " + DistanceFromTarget + " - AngularDamping = " + AngularDamping ); // // // // No matter the choice, engage full thrust below this altitude! // const float FullThrustY = 1500;//1500; // // Console.Error.WriteLine( "TargetX = " + TargetX ); // // Console.Error.WriteLine( "Error = " + ErrorX + ", " + ErrorY ); // // float Angle = AngularDamping * (float) Math.Atan2( ErrorX, ErrorY ); // float PowerX = Math.Min( 4, 2.0f * ErrorX ); // float PowerY = 4 - Math.Min( 4, 0.001f * Math.Max( 0, ErrorY-FullThrustY ) ); // // Console.Error.WriteLine( "PowerX = " + PowerX ); // Console.Error.WriteLine( "PowerY = " + PowerY ); // // string AngleDeg = ((int) (180.0f * Angle / Math.PI)).ToString(); // string PowerSt = ((int) Math.Max( PowerX, PowerY )).ToString(); int newRotation = R; int newThrust = P; ms_simulation.Plan(X, Y, HS, VS, ref newRotation, ref newThrust); Console.WriteLine(newRotation + " " + newThrust); } }