Tier 1
Series 7
7C: The Constant Canopy
"A pilot doesn't memorize that 'Valve 4 must be turned exactly 0.042 degrees.' They look for the label that says 'EMERGENCY SHUTOFF THRESHOLD.' If your AI hides logic behind raw numbers like 0.12f without a name, you've created **Magic Number Fog**. A skilled Engineer audits for **Constants**."
The Concept: Named Constants
A **Constant** is a variable whose value never changes while the game is running. By giving a raw number a name (like MAX_BATTERY_CAPACITY), you make the code self-documenting and prevent "search-and-replace" errors later.
* **Naming:** Use UPPER_CASE_WITH_UNDERSCORES for constants. This makes them stand out instantly during an audit.
* **Keyword:** Use const for simple values (int, float, string) that are known at compile-time.
* **Centralization:** Group your constants at the top of the script so the "Flight Specs" are easy to find.
* **Naming:** Use UPPER_CASE_WITH_UNDERSCORES for constants. This makes them stand out instantly during an audit.
* **Keyword:** Use const for simple values (int, float, string) that are known at compile-time.
* **Centralization:** Group your constants at the top of the script so the "Flight Specs" are easy to find.
Red Flag Detected
The AI Trap: "The Mystery Math"
You ask the AI: "Slow the drone down when it gets close to the landing pad."
// AI-Generated Code: Cryptic and Rigid
void Update() {
// Audit Fail: What do 5.0f and 0.2f represent?
// If you change the landing pad size, you have to hunt for these numbers.
if (Vector3.Distance(pos, pad) < 5.0f) {
speed *= 0.2f;
}
}
This is "Logic Obscurity." Without a label, a new developer (or the AI itself in a later turn) might mistake 5.0f for the drone's altitude or fuel level. A professional pilot demands "Labeled Parameters".
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
// Corrected: Readable and Centralized.
public class Drone : MonoBehaviour {
private const float LANDING_PROXIMITY = 5.0f;
private const float BRAKING_FORCE = 0.2f;
void Update() {
// Audit Pass: The logic is now human-readable.
if (Vector3.Distance(pos, pad) < LANDING_PROXIMITY) {
speed *= BRAKING_FORCE;
}
}
}
Your Pilot Command
> A skilled Mechanic directs the AI to **Define the Constants**. You command: "Replace the raw numbers with constants for the LandingProximity and the BrakingForce."