Skip to content

Latest commit

 

History

History
142 lines (99 loc) · 3.53 KB

File metadata and controls

142 lines (99 loc) · 3.53 KB

Quick Start Guide - Healing Bot Debugging

The Problem You're Experiencing

If you see this error:

The confidence keyword argument is only available if OpenCV is installed.

You're using the wrong Python! Your system has 2 Python installations:

  1. System Python (WindowsApps) - ❌ No OpenCV
  2. Virtual Environment Python - ✅ Has OpenCV

Solution: Always Use the Scripts I Created

Method 1: Use debug_healing.bat (EASIEST)

Double-click or run from PowerShell:

debug_healing.bat

Method 2: Use debug_healing.ps1

From PowerShell:

.\debug_healing.ps1

Method 3: Use Full Path to venv Python

venv\Scripts\python.exe src\actions\healing.py

Method 4: Activate Virtual Environment First

# Activate venv
.\venv\Scripts\Activate.ps1

# Now you can use 'python' normally
python src\actions\healing.py

⚠️ DON'T DO THIS

# This uses the WRONG Python (system Python without OpenCV)
python src\actions\healing.py  # ❌ WRONG!

How to Know Which Python You're Using

Check your Python:

python -c "import sys; print(sys.executable)"

Should say: C:\Users\ghmd8\PycharmProjects\python_practice\venv\Scripts\python.exe

If it says: C:\Users\ghmd8\AppData\Local\Microsoft\WindowsApps\python.exeWRONG!

Verify OpenCV is Available

venv\Scripts\python.exe -c "import cv2; print('OpenCV:', cv2.__version__)"

Should output: OpenCV: 4.12.0

Complete Debug Workflow

  1. Open Puzzles & Survival game

  2. Navigate to Infirmary screen (where you heal troops)

  3. Run the debug script:

    debug_healing.bat
  4. Choose an option:

    • Press 1 to test the plus button
    • Press 2 to test the heal button
    • Press 5 to test the full sequence
  5. Watch it work! The button should be found and clicked

Testing Individual Functions

The debug mode (healing.py) lets you test:

Option Function What It Tests
1 click_plus_button() Finds and clicks the + button to add troops
2 click_heal_button() Finds and clicks the heal button
3 click_clear_button() Finds and clicks the clear button
4 click_help_button() Finds and clicks the help button
5 heal_troops(n) Runs the complete healing sequence

Current Confidence Settings

The following confidence levels are configured in config/settings.py:

  • Plus button: 0.85 (85% match required)
  • Heal button: 0.5 (50% match required)
  • Help button: 0.5 (50% match required)
  • Clear button: 0.5 (50% match required)

These were calibrated based on your actual game screen.

Troubleshooting

"Plus button not found"

  1. Make sure you're on the Infirmary screen
  2. Make sure there are wounded troops to heal
  3. Check that the plus (+) button is visible on screen
  4. Try lowering confidence in config/settings.py:
    PLUS_CONFIDENCE = 0.80  # Try 0.80 instead of 0.85

"Window not found"

Make sure the game window title is exactly: "Puzzles & Survival"

Check with:

venv\Scripts\python.exe -c "import pygetwindow as gw; print([w for w in gw.getAllTitles() if 'Puzzle' in w])"

Need More Help?

Run the image detection diagnostic:

venv\Scripts\python.exe test_image_detection.py

This will test all buttons with various confidence levels and show which ones can be detected.


Remember: Always use debug_healing.bat or the venv Python directly!