Tier
Series 1
1A: The Capacity Check
Pre-Flight
"Imagine a plane traveling 2,000 miles over 5 hours. You use a calculator to find the speed, but you accidentally type 2 divided by 5. The calculator says 0.4.
If you report that the plane is flying at 0.4 mph, you've failed the Sanity Check. You should have expected roughly 400 mph.
In programming, AI is your calculator. If you don't know what the answer *should* look like, you will accept "0.4 mph" code."
If you report that the plane is flying at 0.4 mph, you've failed the Sanity Check. You should have expected roughly 400 mph.
In programming, AI is your calculator. If you don't know what the answer *should* look like, you will accept "0.4 mph" code."
Sanity Check
The Concept: Variables as Containers
In Chapter 1 of our guide, we learn that every piece of data in Unity needs a specific container called a Variable. These containers have a "Capacity" (the Data Type).
int: Whole numbers (Coins, Health, Ammo).
float: Numbers with decimals (Speed, Time, Gravity).
string: Text (Player Name, Dialogue).
bool: True/False (IsGrounded, IsDead).
int: Whole numbers (Coins, Health, Ammo).
float: Numbers with decimals (Speed, Time, Gravity).
string: Text (Player Name, Dialogue).
bool: True/False (IsGrounded, IsDead).
Concept Analysis
Audit Warning
The Audit: Spot the "0.4 mph" Error
You ask the AI: "Track how many gold coins the player has collected." The AI gives you this:
// AI-Generated Code
public string coinCount = "0";
void AddCoin() {
coinCount = coinCount + 1; // ERROR: Can't do math on text!
}
Reasoning: Because a "coin count" is a number you need to add to. Using a string (text) to hold a number is like using a cardboard box to hold a gallon of gasoline—it's the wrong container for the job.
Trap Breakdown
The Pilot's Correction
Operational Protocol Corrected
Solution Logic
// Corrected Code
public int coinCount = 0;
void AddCoin() {
coinCount++; // Simple, efficient, and mathematically correct.
}