If you see the error:
The confidence keyword argument is only available if OpenCV is installed.
This means you're running the bot with the system Python instead of the virtual environment Python that has all dependencies installed.
You have 3 options to run the bot correctly:
run_bot.bat --action heal --times 2.\run_bot.ps1 --action heal --times 2In PowerShell:
.\venv\Scripts\Activate.ps1
python main.py --action heal --times 2In Command Prompt:
venv\Scripts\activate.bat
python main.py --action heal --times 2venv\Scripts\python.exe main.py --action heal --times 2# Heal wounded troops
run_bot.bat --action heal --times 2
# Train troops
run_bot.bat --action train --times 5
# Help alliance members
run_bot.bat --action help --times 3
# Gather resources
run_bot.bat --action gather --times 1
# Check if game window is available
run_bot.bat --action check
# Enable debug logging
run_bot.bat --action heal --times 1 --debugTo check if OpenCV is installed in your current Python environment:
python -c "import cv2; print('OpenCV version:', cv2.__version__)"If this fails, you're not using the virtual environment.
If you need to reinstall dependencies:
# Activate venv first
.\venv\Scripts\Activate.ps1
# Install all dependencies
pip install -r requirements.txtIf you get a script execution error in PowerShell, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserIf the venv folder doesn't exist, create it:
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txtAll 16 unit tests pass:
# Activate venv first, then:
python -m unittest tests.test_healing -v| Command | Description |
|---|---|
run_bot.bat --action heal --times 2 |
Heal troops 2 times |
run_bot.bat --action train --times 5 |
Train troops 5 times |
run_bot.bat --action help --times 3 |
Help alliance 3 times |
run_bot.bat --action gather --times 1 |
Gather resources |
run_bot.bat --action check |
Check game window |
Remember: Always use run_bot.bat or activate the virtual environment before running the bot!