Skip to content

Latest commit

 

History

History
127 lines (90 loc) · 2.78 KB

File metadata and controls

127 lines (90 loc) · 2.78 KB

Puzzles & Survival Bot - Usage Guide

Problem: OpenCV Not Found

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.

Solution: Use the Virtual Environment

You have 3 options to run the bot correctly:

Option 1: Use the Batch Script (Easiest)

run_bot.bat --action heal --times 2

Option 2: Use the PowerShell Script

.\run_bot.ps1 --action heal --times 2

Option 3: Activate Virtual Environment Manually

In PowerShell:

.\venv\Scripts\Activate.ps1
python main.py --action heal --times 2

In Command Prompt:

venv\Scripts\activate.bat
python main.py --action heal --times 2

Option 4: Use Full Path to venv Python

venv\Scripts\python.exe main.py --action heal --times 2

Available Actions

# 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 --debug

Verifying Your Setup

To 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.

Installing Dependencies (if needed)

If you need to reinstall dependencies:

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

# Install all dependencies
pip install -r requirements.txt

Troubleshooting

Issue: "Script execution is disabled on this system"

If you get a script execution error in PowerShell, run:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Issue: Virtual environment not found

If the venv folder doesn't exist, create it:

python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt

Test Results

All 16 unit tests pass:

# Activate venv first, then:
python -m unittest tests.test_healing -v

Quick Reference

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!