AI Command Lab // Flight Simulator
3C: The String Menace
Initial AI Output (Fragile)
// AI-Generated Code: Fragile and Unverifiable
void OnTriggerEnter(Collider other) {
// Audit Fail: If you accidentally name the item "redkey" in the inspector,
// this logic will fail silently. No error will pop up.
if (inventory.HasItem("RedKey")) {
OpenDoor();
}
}
Initial AI Prompt
"You ask the AI: "Check if the player has the 'RedKey' to open the door.""
Pilot Comm Link
Mission Objective: Implement the Observer pattern using C# Events or Actions.
Optimized Protocol
// Corrected: The "Source of Truth"
public static class ItemKeys {
public const string RED_KEY = "RedKey";
}
void OnTriggerEnter(Collider other) {
// The IDE will now help you: typing "ItemKeys." shows you all options
if (inventory.HasItem(ItemKeys.RED_KEY)) {
OpenDoor();
}
}