Spaces:
Sleeping
Sleeping
File size: 5,623 Bytes
8d87603 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# ๐ค Heuristic Analysis - Quick Answer
## What does "heuristic" mean?
**Heuristic** = **Rule-based** analysis, NOT using the AI model.
---
## ๐ฏ Simple Comparison
### ๐ค LLM Analysis (AI Model)
```
Uses: Qwen2.5-Coder-1.5B language model
Time: ~15 seconds
Quality: โญโญโญโญโญ Very specific and natural
Example:
"Your tank forces are positioned well but enemy
helicopters are harassing your northwest harvesters.
Build SAM sites near refineries and advance your
tank column while they're distracted."
```
### ๐ Heuristic Analysis (Simple Rules)
```
Uses: IF-THEN rules (count units, compare numbers)
Time: Instant (0.001 seconds)
Quality: โญโญโญ Generic but always correct
Example:
"Battlefield is balanced. Scout and take map control.
Build more units and protect your harvesters."
```
---
## โก Why Use Heuristic?
### 3 Reasons:
1. **Model Not Ready** โณ
- Game just started
- Model still loading (takes 15s)
- Heuristic gives instant advice while waiting
2. **Model Busy** ๐
- LLM processing another request
- You get heuristic INSTANTLY
- Better than waiting or getting nothing
3. **Model Timeout** โ
- LLM taking too long (>15s)
- Automatic fallback to heuristic
- Guaranteed advice, always works
---
## ๐ How It Works
```python
# Heuristic = Simple Math + Rules
1. COUNT everything:
- Your units: 10
- Enemy units: 8
- Your buildings: 5
- Enemy buildings: 4
2. CALCULATE score:
score = (10-8) + 0.5ร(5-4) = 2.5
3. DETERMINE situation:
score > 1 โ "You're AHEAD"
4. SELECT advice:
"You hold the initiative.
Maintain pressure and expand."
5. ADD specific tips:
- Low power? โ "Build Power Plant"
- Low credits? โ "Protect Harvester"
- Fewer units? โ "Train Infantry and Tanks"
6. DONE! (0.001 seconds)
```
---
## ๐ฎ What You See
### Both Look Professional:
**LLM Analysis:**
```
โโโโโโโโโโโโโโโโโโโ
Summary: Your tank forces are positioned
well in the center. Enemy is vulnerable
on north flank - consider flanking attack
with infantry support.
Tips:
โข Build 2 more tanks for flanking force
โข Send infantry to north position
โข Protect harvesters during advance
โข Scout enemy rear for vulnerabilities
Coach: Great positioning! Execute the
flank now while enemy is committed south.
โโโโโโโโโโโโโโโโโโโ
```
**Heuristic Analysis:**
```
โโโโโโโโโโโโโโโโโโโ
Summary: You hold the initiative.
Maintain pressure and expand.
Tips:
โข Train Infantry and add Tanks
โข Scout enemy base position
โข Protect Harvester and secure ore
โข Build Power Plant if needed
Coach: Keep your economy safe and
strike when you see an opening.
โโโโโโโโโโโโโโโโโโโ
```
**Notice:**
- Heuristic is more **generic** but still **useful**
- LLM is more **specific** to your exact situation
- Both provide **valid tactical advice**
---
## โ
Benefits of Heuristic
| Benefit | Description |
|---------|-------------|
| **Instant** | No waiting (0.001s vs 15s) |
| **Reliable** | Never fails, always works |
| **No CPU** | Doesn't use model (saves resources) |
| **Fallback** | Guarantees users always get advice |
| **Multi-language** | English, French, Chinese support |
---
## ๐ฏ Bottom Line
### Question: Is heuristic analysis bad?
**Answer: NO!** It's a **smart fallback system**.
### Think of it like:
```
๐ค LLM = Professional coach analyzing replay (15s)
โ Amazing advice, very specific
๐ Heuristic = Quick tips from experienced player (instant)
โ Good advice, always available
```
**Both are useful!**
- Heuristic ensures you **ALWAYS** get advice
- LLM makes the advice **AMAZING** when available
### System Design:
```
Try LLM first (best quality)
โ
If busy/timeout โ Use Heuristic (instant backup)
โ
User gets advice ALWAYS โ
```
---
## ๐ How to Tell?
Check the `source` field in the response:
```json
{
"summary": "...",
"tips": [...],
"coach": "...",
"source": "heuristic" โ This tells you!
}
```
Or:
```json
{
"summary": "...",
"tips": [...],
"coach": "...",
"source": "llm" โ Using AI model
}
```
---
## ๐ Real Example from Game
### Scenario: You just sent 3 NL commands quickly
```
[00:00] You: "move tanks north" โ LLM busy (15s)
[00:01] You: "build infantry" โ LLM queued
[00:02] You: "attack enemy base" โ LLM queued
[00:03] AI Analysis triggers...
โ LLM busy with your commands!
โ Heuristic returns INSTANTLY โ
You see: "Battlefield is balanced. Scout
and take map control."
[00:18] LLM finishes your commands
[00:35] Next AI analysis uses LLM โ
You see: "Your tank column is advancing
well. Enemy is fortifying north
position - consider flanking from
east instead."
```
**You got advice at both times!**
- First: Heuristic (instant, generic but useful)
- Second: LLM (waited, specific and strategic)
---
## ๐ Summary
**Heuristic = Smart instant fallback**
- Not AI, just simple rules
- Instant response (no waiting)
- Always works (100% reliable)
- Generic but valid advice
- Ensures you NEVER wait without feedback
**It's a FEATURE, not a bug!** โ
The game prioritizes **user experience**:
- Fast response > Perfect response
- Some advice > No advice
- Reliable > Fancy
When the LLM is available and not busy, you get the amazing AI analysis. When it's busy, you get instant heuristic advice. **Win-win!** ๐ฏ
|