Tier 1 Series 8

8C: The Pyramid of Doom

Pilot Record
Student Profile
"If you need 5 keys to open 5 nested doors just to turn on the light, the room is designed wrong. Don't nest your logic deep inside brackets. Check the requirements at the door, then let them in."

The Concept: Guard Clauses

Instead of wrapping code in layers of `if (alive) { if (hasAmmo) { if (enemyNear) { ... } } }`, use **Guard Clauses** to return early.

* **Return Early:** `if (!alive) return;`
* **The Benefit:** This keeps your actual logic indented only once, making it readable and clean.
Red Flag Detected

The Audit: The Spaghetti Nest

Ask the AI to shoot only if alive and armed.

void Shoot() {
    if (isAlive) {
        if (hasAmmo) {
            if (target != null) {
                Fire();
            }
        }
    }
}

This is "Arrow Code." The logic is pushed so far to the right it becomes hard to read. It causes "Cognitive Load" for the pilot.

Elite Telemetry

Research shows "Elite" teams achieve 15% faster lead times by keeping AI on a "very tight leash."

  • Small Batches Solving one problem at a time prevents logic drift.
  • Modular Design Localizing the "blast radius" of AI changes.
  • Tight Loops Rapid iteration with constant code review.

The Mechanic's Correction

Corrective Protocol
void Shoot() {
    // AUDIT PASS: Check failures first.
    if (!isAlive) return;
    if (!hasAmmo) return;
    if (target == null) return;

    Fire();
}
Your Pilot Command
> A skilled Mechanic directs the AI to use Guard Clauses.
Next Mission