The Bytecode Club
Log inJoin the club
Video Game Reverse Engineering

Developing Bot

Started by Antidote · Dec 5, 2014

1,033 replies21,297,466 viewsLocked
Dec 20, 2014#151

Also, i dont have any issue with imagesearch on barracks, troops etc. But i'm developing my bot in java, notre using autour.

Dec 20, 2014#152

Also, i dont have any issue with imagesearch on barracks, troops etc. But i'm developing my bot in java, notre using autour.

what pixel size are the images your are searching for? and how much accuracy do you use?

Dec 20, 2014#153

Same problem as MDMA. I also have level 5 walls so that may be the issue however it isn't clicking the walls, it just never clicks the attack button to start looking for targets.
Also it seems like it has trouble recognizing that clash of clans is open. If I repeatedly zoom in and out it recognizes it.
I made this account just to let you know and help out in anyway I could. Good luck man.

Try to change the $Attack Value from 0xF0E5D6 to 0xD39783 and let me know if it worked 😉

Dec 20, 2014#154

Sorry guys I've been caught up with work the last few days but finally have time to code now. Really happy to see lots of you guys contribute :D
@AtoZ: How's your progress with imagesearch? I noticed all image file in coc-en folders with red background. Did you manage to use imagesearch with that one or your own? Locking it in a loop might be a good idea, I'm gonna go back to imagesearch and try again later.
@odySSeys: really appreciate your efforts man. Last time I just gave up after 2hours+ lol. Tested it out a few times and results seem to be better but not 100% unfortunately. I'll need more time to test it.
@vanadium: snowflakes does seem to be an issue for me though. When I compare tesseract readings with captured image, clear image gives nearly 100% accuracy while image with snowflakes seem to distort the reading. Maybe I'll have to try glyph.
@kojometa: thanks mate, I've sorted out errors and will make modification soon. Most errors are from check function as I'm still optimizing it, all basic function works fine. Understand how you feel though, there are days when I spend 10 hours coding nonstop lol.
@GkevinOD: impressive work bro! haven't tested it out but seems like the one vanadium was talking about, just specifc to gold in game. I'll read through it and try to implement

Dec 20, 2014#155

I've looked through all errors and make modifications to the code. Here's the latest installer:
http://www22.zippyshare.com/v/55848174/file.html
Source: https://pastebin.com/ry8RJEqr

Basically what it does is extract Tesseract-OCR, BS-Resolution folders and Source.au3. I've included the source inside the installer so you can run straight from the installer or make your modification to the source and compile from there. I think this is the most convinient way for everyone to start on working/testing the code without having to go through Tesseract setting and traineddata. Here's the changes I made:

  • Use coord for button. I've been experimenting with PixelSearch and PixelGetColor but since colors are a bit tricky I'll just stick to coord from now.
  • Use PixelCheckSum for main screen check. Since the screen become static when an error message appear, pixelchecksum is much more reliable than pixelgetcolor.  
  • Let the script wait around 2min40s after dropping troops before pressing return home since I can't reliably determine when battle finish. Rotating light in the background make pixelchecksum useless
  • Script send 30 down button instead of 20 to ensure screen is completely zoomed out. I can't find a way to determine if it has been fully zoomed out. If anyone manage to do it it would prevent lots of possible errors.
  • Add Locate Barrack, Train, Attack and Village Search button for easier testing. You can test each part individually to test if there's error.
    To use Village Search, make sure you are fully zoomed out, click attack, find a match and click Village Search. It will begin searching until match is found. If you want to continue searching, just click again.

A few things to note:

  • When you first start the script, it will look like it's clicking randomly on the screen. This is just the script trying to zoom out (repeatedly press Down button on keyboard)
  • Gold & Elixir readings are currently only about 60 to 70% accurate. I and many people here are working on a way to improve it, in the mean time just expect some possible mismatch, the script is just intended for testing only.
  • Troops are deployed according to the selection in barrack drop down, not according to your army camps. So if your army camps contain troops that are not in the selection, it'll likely to mess it up. To read army camp I'll have to get imagesearch to work.
  • For now troops deployment are not effective. I just put around 3 giants, ~30 barbarian, ~30 archers per wave near the edge for testing.
Dec 20, 2014#156

Sorry guys I've been caught up with work the last few days but finally have time to code now. Really happy to see lots of you guys contribute :D
@AtoZ: How's your progress with imagesearch? I noticed all image file in coc-en folders with red background. Did you manage to use imagesearch with that one or your own? Locking it in a loop might be a good idea, I'm gonna go back to imagesearch and try again later.
@odySSeys: really appreciate your efforts man. Last time I just gave up after 2hours+ lol. Tested it out a few times and results seem to be better but not 100% unfortunately. I'll need more time to test it.
@vanadium: snowflakes does seem to be an issue for me though. When I compare tesseract readings with captured image, clear image gives nearly 100% accuracy while image with snowflakes seem to distort the reading. Maybe I'll have to try glyph.
@kojometa: thanks mate, I've sorted out errors and will make modification soon. Most errors are from check function as I'm still optimizing it, all basic function works fine. Understand how you feel though, there are days when I spend 10 hours coding nonstop lol.
@GkevinOD: impressive work bro! haven't tested it out but seems like the one vanadium was talking about, just specifc to gold in game. I'll read through it and try to implement

In the meantime i tested some more stuff out.
Current status: I modified the code to always show me in what function he is atm.
It gets stuck in the ReadValue Funcion!
If you look into the taskmanager it opens tesseract.exe for a seconds, waits a few seconds, and tesseract.exe opens again.

Unfortunately i got no experience with tesseract at all. Do you know how to debug this error? I also think some checks and sleeps would prevent a lot of errors! 😉

Dec 20, 2014#157

@Antidote I am currently working on making the function faster and I'm close to accomplishing that.

I am also going to work on making a function that searches for the elixir. Also, because it has the same colors as trophy count, DE, and the gold-elixir count at the right side it can be used for all those data as well.

Dec 20, 2014#158

I've looked through all errors and make modifications to the code. Here's the latest installer:
http://www3.zippyshare.com/v/39333226/file.html

Basically what it does is extract Tesseract-OCR, BS-Resolution folders and Source.au3. I've included the source inside the installer so you can run straight from the installer or make your modification to the source and compile from there. I think this is the most convinient way for everyone to start on working/testing the code without having to go through Tesseract setting and traineddata. Here's the changes I made:

  • Use coord for button. I've been experimenting with PixelSearch and PixelGetColor but since colors are a bit tricky I'll just stick to coord from now.
  • Use PixelCheckSum for main screen check. Since the screen become static when an error message appear, pixelchecksum is much more reliable than pixelgetcolor.  
  • Let the script wait around 2min40s after dropping troops before pressing return home since I can't reliably determine when battle finish. Rotating light in the background make pixelchecksum useless
  • Script send 30 down button instead of 20 to ensure screen is completely zoomed out. I can't find a way to determine if it has been fully zoomed out. If anyone manage to do it it would prevent lots of possible errors.
  • Add Locate Barrack, Train, Attack and Village Search button for easier testing. You can test each part individually to test if there's error.
    To use Village Search, make sure you are fully zoomed out, click attack, find a match and click Village Search. It will begin searching until match is found. If you want to continue searching, just click again.

A few things to note:

  • When you first start the script, it will look like it's clicking randomly on the screen. This is just the script trying to zoom out (repeatedly press Down button on keyboard)
  • Gold & Elixir readings are currently only about 60 to 70% accurate. I and many people here are working on a way to improve it, in the mean time just expect some possible mismatch, the script is just intended for testing only.
  • Troops are deployed according to the selection in barrack drop down, not according to your army camps. So if your army camps contain troops that are not in the selection, it'll likely to mess it up. To read army camp I'll have to get imagesearch to work.
  • For now troops deployment are not effective. I just put around 3 giants, ~30 barbarian, ~30 archers per wave near the edge for testing.

Could you upp the code itself to pastbin again? Would be awesome. Its not against you but i mostly feel unconforable opening .exe 😉

Dec 20, 2014#160

nice, thats perfect! 🙂
thanks a lot!

i also tested the script of GkevinOD and at it works incredibly good for me as wel!
i think that in the future it would definetly be the better option than tesseract.

This discussion is closed.