Challenge - 5 Problems
AI Game Challenge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Unity C# AI decision code?
Consider this simple AI decision code snippet in Unity C#. What will be printed when the AI's health is 30?
Unity
int health = 30; string action; switch (health) { case int h when (h > 50): action = "Attack"; break; case int h when (h > 20): action = "Defend"; break; default: action = "Retreat"; break; } Debug.Log(action);
Attempts:
2 left
💡 Hint
Think about which case matches when health is 30.
✗ Incorrect
The health is 30, which is greater than 20 but not greater than 50, so the 'Defend' case runs.
🧠 Conceptual
intermediate1:30remaining
Why does AI unpredictability increase game challenge?
Which of these best explains why AI unpredictability makes games more challenging?
Attempts:
2 left
💡 Hint
Think about how players react to patterns.
✗ Incorrect
If AI is predictable, players can learn and exploit patterns, making the game easier. Unpredictability forces players to adapt.
🔧 Debug
advanced2:30remaining
Find the error causing AI to always attack in Unity C#
This AI code is supposed to choose between attacking or retreating based on health, but it causes a compile error. What is the bug?
Unity
int health = 10; string action; if (health > 20) action = "Attack"; else if (health < 20) action = "Retreat"; Debug.Log(action);
Attempts:
2 left
💡 Hint
Check if all health values are covered by conditions.
✗ Incorrect
When health is exactly 20, neither condition matches, so 'action' remains unassigned, causing unexpected behavior.
📝 Syntax
advanced2:00remaining
Which option causes a syntax error in Unity C# AI code?
Which of these AI code snippets will cause a syntax error when compiled?
Attempts:
2 left
💡 Hint
Check the syntax of the if statement.
✗ Incorrect
In C#, the if condition must be inside parentheses. Option A misses parentheses causing syntax error.
🚀 Application
expert3:00remaining
How many unique actions can this AI perform?
Given this Unity C# AI code, how many unique actions can the AI perform?
Unity
int health = 40; int enemyDistance = 10; string action; if (health > 50 && enemyDistance < 5) { action = "Attack"; } else if (health > 20 || enemyDistance < 10) { action = "Defend"; } else { action = "Retreat"; } Debug.Log(action);
Attempts:
2 left
💡 Hint
Count all possible distinct actions from the conditions.
✗ Incorrect
The AI can choose 'Attack', 'Defend', or 'Retreat' depending on health and enemyDistance values.