AI Command Lab // Flight Simulator
2A: The Switchboard
Initial AI Output (Fragile)
// AI-Generated Code (Nested Mess)
public string GetPower(FlightPhase phase) {
if (phase == FlightPhase.Idle) {
return "Low";
} else {
if (phase == FlightPhase.Takeoff) {
return "Maximum";
}
}
return "Unknown";
}
Initial AI Prompt
"You ask the AI: "Check the flight phase and return the engine power level.""
Pilot Comm Link
Mission Objective: Physics-based movements belong inside the FixedUpdate method.
Optimized Protocol
// Corrected Code
public string GetPower(FlightPhase phase) => phase switch
{
FlightPhase.Idle => "Low",
FlightPhase.Takeoff => "Maximum",
_ => "Unknown" // The safety net
};