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:
- System Python (WindowsApps) - ❌ No OpenCV
- Virtual Environment Python - ✅ Has OpenCV
Double-click or run from PowerShell:
debug_healing.batFrom PowerShell:
.\debug_healing.ps1venv\Scripts\python.exe src\actions\healing.py# Activate venv
.\venv\Scripts\Activate.ps1
# Now you can use 'python' normally
python src\actions\healing.py# This uses the WRONG Python (system Python without OpenCV)
python src\actions\healing.py # ❌ WRONG!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.exe ← WRONG!
venv\Scripts\python.exe -c "import cv2; print('OpenCV:', cv2.__version__)"Should output: OpenCV: 4.12.0
-
Open Puzzles & Survival game
-
Navigate to Infirmary screen (where you heal troops)
-
Run the debug script:
debug_healing.bat
-
Choose an option:
- Press
1to test the plus button - Press
2to test the heal button - Press
5to test the full sequence
- Press
-
Watch it work! The button should be found and clicked
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 |
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.
- Make sure you're on the Infirmary screen
- Make sure there are wounded troops to heal
- Check that the plus (+) button is visible on screen
- Try lowering confidence in
config/settings.py:PLUS_CONFIDENCE = 0.80 # Try 0.80 instead of 0.85
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])"Run the image detection diagnostic:
venv\Scripts\python.exe test_image_detection.pyThis 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!