linus-jansson / btd6farmer

A tool to make autonomous macros in Bloons Td 6. Relies on OCR and template matchmating for navigation. Made in python
https://discord.gg/qyKT6bzqZQ
MIT License
32 stars 11 forks source link

Bot starts game, but does not place any towers to pop balloons #15

Closed jason00-r closed 2 years ago

jason00-r commented 2 years ago

The bot won't place any monkey towers. It just starts the first round. After issue #12 was fixed, this is the new behavior.

jason00-r commented 2 years ago

bot will do nothing and the game will end due to 0 hearts left

linus-jansson commented 2 years ago

What OS are you running on? Do you have any custom keybinds?

I can't seem to reproduce the issue

jason00-r commented 2 years ago

What OS are you running on? Do you have any custom keybinds?

I can't seem to reproduce the issue

Running Windows 11. All hotkeys in-game are the defaults. No custom keybinds outside of the game either.

jason00-r commented 2 years ago

In the game, my screen size is set to 2560x1440 in the settings. I tried in both full screen and windowed mode. Both just start and do not place any towers.

linus-jansson commented 2 years ago

Could you try with the latest release and see if anything happens now?

jason00-r commented 2 years ago

Could you try with the latest release and see if anything happens now?

That did not fix the issue.

I did notice that the cursor moved to the left of the map quickly and I circled the area roughly with a white circle in the screenshot below.

image

jason00-r commented 2 years ago

In that screenshot I have the cursor set to X-Large, but I also have tried with the normal size. It did not help.

linus-jansson commented 2 years ago

Could you check what python version you have with py --version in your CMD or terminal? Also do a pip freeze and send the output here

jason00-r commented 2 years ago

Could you check what python version you have with py --version in your CMD or terminal? Also do a pip freeze and send the output here

C:\Users\Jason>py --version Python 3.10.5

C:\Users\Jason>pip freeze Fatal error in launcher: Unable to create process using '"c:\program files\python39\python.exe" "C:\Program Files\Python39\Scripts\pip.exe" freeze': The system cannot find the file specified.

C:\Users\Jason>python -m pip freeze keyboard==0.13.5 mouse==0.7.1 MouseInfo==0.1.3 numpy==1.22.3 opencv-python==4.5.5.64 packaging==21.3 Pillow==9.1.1 PyAutoGUI==0.9.53 PyGetWindow==0.0.9 PyMsgBox==1.0.9 pyparsing==3.0.9 pyperclip==1.8.2 PyRect==0.2.0 PyScreeze==0.1.28 pytesseract==0.3.9 pytweening==1.0.4

char-ptr commented 2 years ago

i also encounter this issue, the game starts and it places no towers. i can provide the same statistics also on w11.

✖-1073741510 ✗  py -3.10 --version
Python 3.10.5
➜  py -3.10 -m pip freeze
keyboard==0.13.5
mouse==0.7.1
MouseInfo==0.1.3
numpy==1.22.3
opencv-python==4.5.5.64
packaging==21.3
Pillow==9.2.0
PyAutoGUI==0.9.53
PyGetWindow==0.0.9
PyMsgBox==1.0.9
pyparsing==3.0.9
pyperclip==1.8.2
PyRect==0.2.0
PyScreeze==0.1.28
pytesseract==0.3.9
pytweening==1.0.4
char-ptr commented 2 years ago

After debugging i have figured out that it is due to the ocr being wildly inaccurate spewing out inconstant results image (don't even try with autohdr as there is no hope)

linus-jansson commented 2 years ago

Woah thats way off..

Could always try with implementing tesserocr instead of pytesseract, but I think it will just improve the performance and not the accuracy. I also found PaddleOCR which can be tested, maybe that will fix the issue!

After debugging i have figured out that it is due to the ocr being wildly inaccurate spewing out inconstant results

Would it be possible if you could try to view the image that its capturing on your instance by adding:

cv2.imshow('Screenshot', numpyImage)
cv2.waitKey(0)
cv2.destroyAllWindows()

in https://github.com/linus-jansson/btd6farmer/blob/5803d6e1c55a5912543844e358143d51de869e21/bot.py#L67-L72 on line 72 to see if it is even capturing the right place of the screen?

char-ptr commented 2 years ago

I've already looked at the images it's produced and they don't look particularly wrong but I'll upload the images for the stages when I'm back on my computer.

char-ptr commented 2 years ago

this is what tensorflow sees: pog2

this is the image which is captured before post processing / converting to black and white: temp

hope these images help improve the software [my resolution is 5120x1440 so that's why there is excess black pixels but that should be happening i think due to padding mechanism]

linus-jansson commented 2 years ago

I realized that the width and height of the screenshot shouldn't be scaled depending on the monitor res. (that results in your case that the upgrade button is shown which it shouldn't really)

Try with the latest commit to see if that changes anything?

Edit: Don't really think that this would fix the main issue as @jason00-r has the same res as i'm testing on which still should capture in the correct way without any padding..

Jason would it be possible for you to send what round the program think its on by adding print(text) on line 81 in bot.py?

https://github.com/linus-jansson/btd6farmer/blob/dfb5635eb622506e77b061983ffc5db46fd39593/bot.py#L80-L86

jason00-r commented 2 years ago

I realized that the width and height of the screenshot shouldn't be scaled depending on the monitor res. (that results in your case that the upgrade button is shown which it shouldn't really)

Try with the latest commit to see if that changes anything?

Edit: Don't really think that this would fix the main issue as @jason00-r has the same res as i'm testing on which still should capture in the correct way without any padding..

Jason would it be possible for you to send what round the program think its on by adding print(text) on line 81 in bot.py?

https://github.com/linus-jansson/btd6farmer/blob/dfb5635eb622506e77b061983ffc5db46fd39593/bot.py#L80-L86

Your most recent commit seems to fix the issue for me. I will run through a full game to verify.

Sorry I didn't clarify - I also have an ultrawide monitor with the same resolution so I have the black on the side as well. The resolution I mentioned before was what the game was set to.

jason00-r commented 2 years ago

Something appears to be wrong still.

I got a defeat at round 35 from camo balloons. Dart monkeys were not being upgraded at all.

Then after restarting the script, I got a defeat at round 63 with $38,964. dart monkey1 0-0-2 dart monkey2 0-0-0 super monkey 0-0-1 both sub 2-0-3 alchemist 3-0-0 obyn placed and level 13 both monkey villages 0-0-2

linus-jansson commented 2 years ago

Something appears to be wrong still.

I got a defeat at round 35 from camo balloons. Dart monkeys were not being upgraded at all.

Then after restarting the script, I got a defeat at round 63 with $38,964. dart monkey1 0-0-2 dart monkey2 0-0-0 super monkey 0-0-1 both sub 2-0-3 alchemist 3-0-0 obyn placed and level 13 both monkey villages 0-0-2

I will open that in a new issue to seperate the subjects a bit

jason00-r commented 2 years ago

Something appears to be wrong still. I got a defeat at round 35 from camo balloons. Dart monkeys were not being upgraded at all. Then after restarting the script, I got a defeat at round 63 with $38,964. dart monkey1 0-0-2 dart monkey2 0-0-0 super monkey 0-0-1 both sub 2-0-3 alchemist 3-0-0 obyn placed and level 13 both monkey villages 0-0-2

I will open that in a new issue to seperate the subjects a bit

That makes sense. I will close this issue then. My original issue of no towers being placed is solved.