AI Command Lab // Flight Simulator
302B: The Strategy Switch
Initial AI Output (Fragile)
// AI-Generated Code: The "God" Method
void Move() {
// Audit Fail: This function will grow to 500 lines.
if (mode == "Fly") { ... }
else if (mode == "Walk") { ... }
else if (mode == "Swim") { ... }
}
Initial AI Prompt
"You ask the AI: "Handle movement for flying, walking, and swimming.""
Pilot Comm Link
Mission Objective: A skilled Navigator directs the AI to use Strategies.
Optimized Protocol
// Corrected: Modular & Swappable
public interface IMovementStrategy { void Move(Transform t); }
public class Player : MonoBehaviour {
private IMovementStrategy _strategy;
public void SetMode(IMovementStrategy newMode) {
_strategy = newMode;
}
void Update() => _strategy.Move(transform);
}