Tier
Series 1
1C: Logic Gateways
Pre-Flight
"A pilot doesn't just 'land.' They follow a checklist: IF the altitude is correct, AND the gear is down, AND the runway is clear, THEN they land. If even one 'IF' is missing, the result is a disaster."
Sanity Check
The Concept: Comparison & Logic
In Chapter 2, we explore how C# uses Operators to compare values. As an AI Pilot, you must ensure the AI is using the correct "Checklist" before performing a game action.
== Is Equal To
&& AND (Both True)
|| OR (Either True)
== Is Equal To
&& AND (Both True)
|| OR (Either True)
Concept Analysis
Audit Warning
The AI Trap: "The Impossible Purchase"
You give an AI a vague instruction like "Write a function to let the player buy an upgrade that costs 50 coins."
// Vague Prompt Result: Fails the Sanity Check
void BuyUpgrade() {
coinCount -= 50;
Debug.Log("Upgrade Purchased!");
}
Reasoning: Without a check, a player with 10 coins ends up with -40. You've allowed the calculator to give an "impossible" answer.
Trap Breakdown
The Pilot's Command
Operational Protocol Corrected
Solution Logic
// Result of a Guided Prompt
void BuyUpgrade() {
if (coinCount >= 50) {
coinCount -= 50;
Debug.Log("Upgrade Purchased!");
} else {
Debug.Log("Not enough coins!");
}
}