Spaces:
Sleeping
Sleeping
| # ๐ค 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!** ๐ฏ | |