CodeSlinger69/ClAsHbOt

Open discussion thread

CodeSlinger69 opened this issue · 142 comments

Since GitHub does not provide discussion forums, and since the ClAsHbOt code base is fairly stable now, I thought I would open this "Issue" as a general thread for any general discussion items. If you have a bug report or feature request, please open a separate issue. No other rules apply to this thread, and I'll keep it permanently open.

An open discussion thread is a great idea.

With the previous build I'm still having color-recognition problems on the army screen. I've been busy lately, but will let you know if tweaking the color fixes the issue.

That is strange, Dean, especially since the army-queueing is done by image recognition. IIRC, maybe you were having problems with buttons being recognized? If you can share a screenshot that will help. Some more details on your environment might help too, such as the BlueStacks version, are you running in a VM, Windows version, etc. If you open up a new thread, we can work through this and get it solved.

Current stats 7/29/2015. This is 98% bot:

  • Gold Grab: 1,564,000,000
  • Elixir Escapade: 1,594,000,000
  • Heroic Heist: 4,489,000
  • Conqueror: 11,000

46 blue walls, 204 lava walls.

In case anyone is curious, I upgraded to Windows 10 last night. ClAsHbOt still works great! No problems whatsoever to report.

Any plans to have background mode so can hide window and we can still do other things with the computer?

Heya, CiRc. For the bot to work, it needs to be able to see the pixels on the screen to derive the game state. In a hidden window, the pixels are no visible and thus the bot won't work.

A great alternative is to run BlueStacks and the bot in a VMWare Player VM. That way you can minimize the VM window and be able to do other things.

I've been playing the Witcher 3 lately, while the bot runs in a minimized VM window. Seems to work fine.

I am sure you aware about there other bots that can https://gamebot.org/
Open Source bot but for me has way to many features. I just started playing
the game less then a week ago. The advance stuff they have is of no use to
me. They say the Background hide window works because of windows Areo
desktop. If its not installed you cant hide the window where there bot can
see sit the screen pixels,

On Tue, Aug 11, 2015 at 9:46 AM, CodeSlinger69 notifications@github.com
wrote:

Heya, CiRc. For the bot to work, it needs to be able to see the pixels on
the screen to derive the game state. In a hidden window, the pixels are no
visible and thus the bot won't work.

A great alternative is to run BlueStacks and the bot in a VMWare Player
VM. That way you can minimize the VM window and be able to do other things.

I've been playing the Witcher 3 lately, while the bot runs in a minimized
VM window. Seems to work fine.


Reply to this email directly or view it on GitHub
#22 (comment)
.

Other bots are just moving bluestack window out of sight.

ClashGameBot: WinMove($Title, "", -32000, -32000)

Interesting, thanks rumbla. I'll do some investigation into that solution. My concerns are if there are differences between Windows versions, or video card drivers that might make it work in some cases but not others.

Btw, I gotta say I'm really impressed by you bot. It really plays like a human would do.
Although, I don't understand why you did not just use a resolution to show the entire village (1024x820). The bot would not "scroll" up&down that way.
Also, did you use mouse movements to mimic a human? As far as I know, you can click a window without taking control of the mouse pointer (and probably, you want to do that, if you wanna move BlueStacks' window like other bots do).

SideNote/FeatureRequest:
I used the bot briefly with a th7 village. I noticed that GiBarc always attack from the top corner.
Would be lovely having the bot attacking the side where most collectors are.
In fact, once, attacking from the top corner all these juicy collector on the bottom side were still intact 😄

👍 for the opensource dll. Something noone else has done, till now.

rumbla:

  • resolution: I use a standard cell phone resolution. I have a lot of experience writing bots for games, and one of the easiest ways to detect botters is to search for unusual working resolutions. There is no such thing as a square screen, unless you are a botter. It is a bit more work to scroll around, but on the other hand, the possibility of detection is much reduced.
  • mouse: I do attempt to mimic human mouse movements and clicking as much as possible.
  • clicking without taking control of pointer: look in the .ini file for this option: "Click Method" in the [Mouse] section.
  • th7/GiBarch: This could very well be a bug. I've mentioned in the readme/wiki/some where, that I didn't start using this bot until TH8, as I believe there is really no need to do so. As such, I do not have images of TH7 level buildings. The log file may very well tell you what is going on here. That said, the point of GiBarch is to be able to penetrate into the core and harvest the storages, so what the bot should be looking for is the best way to attack the base with the intent of getting to those storages. Collectors are not a factor in this kind of attack. If it is always attacking from the top corner, there is likely a problem, which is probably that the bot can't find the storages, due to the above mentioned TH8 problem.

Hi CodeSlinger,

i just downloaded this awesome tool, and started playing with it. I noticed few things i would like to see some improvements in, but i would like to spend few days playing with it before i bring out the list of questions and possible improvements.

Thanks for your effort.

Glad to have you here, warclans. I look forward to hearing your ideas.

Hello,
Nice work CodeSlinger.
For background mode, use some WinAPI functions, the autoit3 code example:

;Saves a screenshot of a window app. into memory (capture)

Func _Example_Region($iLeft = 0, $iTop = 0, $iRight = 860, $iBottom = 720, $ReturnBMP = False)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hHBitmap)

    If $ichkBackground = 1 Then
        Local $iW = Number($iRight) - Number($iLeft), $iH = Number($iBottom) - Number($iTop)
        Local $hDC_Capture = _WinAPI_GetWindowDC(ControlGetHandle($Title, "", "[CLASS:BlueStacksApp; INSTANCE:1]"))
        Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture)
        $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW, $iH)
        Local $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap)
        DllCall("user32.dll", "int", "PrintWindow", "hwnd", $HWnD, "handle", $hMemDC, "int", 0)
        _WinAPI_SelectObject($hMemDC, $hHBitmap)
        _WinAPI_BitBlt($hMemDC, 0, 0, $iW, $iH, $hDC_Capture, $iLeft, $iTop, 0x00CC0020)
        Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
        _WinAPI_DeleteDC($hMemDC)
        _WinAPI_SelectObject($hMemDC, $hObjectOld)
        _WinAPI_ReleaseDC($HWnD, $hDC_Capture)
    Else
        getBSPos()
        $hHBitmap = _ScreenCapture_Capture("", $iLeft + $BSpos[0], $iTop + $BSpos[1], $iRight + $BSpos[0], $iBottom + $BSpos[1])
        Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    EndIf
    If $ReturnBMP Then Return $hBitmap
EndFunc   ; _Example_Region

May be usefull: Capture a minimized window screenshot disscution, the link
http://www.rohitab.com/discuss/topic/34197-capture-a-minimized-window-screenshot/
and
Window Contents Capturing using WM_PRINT Message, the link http://www.fengyuan.com/article/wmprint.html
Also the C# article :
http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick

Best regards,

As general discussion, I was wondering if there was a better way to detect the dead bases.
I can see bases that have a lot of gold / elixir in their collector.

Would it be possible to do image recognition on the collectors / mines and find the ones that are full?

It may be tricky as there would be very few pixel difference between empty / full collector, but that could dramatically increase the loot especially for Barcher.

Hi there,

"As general discussion, I was wondering if there was a better way to detect the dead bases.
I can see bases that have a lot of gold / elixir in their collector."

I know of much better way :) but i don't know how this could be incorporated into the current bot. I can read and decrypt the packets, so i know exactly position of the traps/hidden/ elements as well as if they are armed or not, their level, exact resource count per storage, collectors. If CodeSlinger is interested, maybe we could make a better tool together?

@warclans Can you even read Workers' and Shield Timers? I would love a "Reading Memory" lib for the tool I'm working on.

​Getting all the ​data would mean (I assume here) that you got access to the API data in some way between the client and SC server.
AutoIT is primarily working on visual aspect, and click automation. which is not "raw" data reading.
Getting the data out of Bluestack as well can present a challenge as it would mean rooting Bluestack (I assume here as well).
Just my 2 cents but that would be great to have :)

@rumbla Shield Timer can be read by Getting the Shield Timer Box Location (and edit the RegionDefs.au3 accordingly) - as well as choosing the correct "font" in CharMaps.au3

You can take example with the Gems: https://github.com/CodeSlinger69/ClAsHbOt/search?utf8=%E2%9C%93&q=Gems

@rumbla Yes, i can read that as well.

My idea is to make a proxy (yes it will require host change on BlueStacks to point to local IP instead - Hosts App would do), and provide all the relevant info to bot through api. This way there would be time reduction in scanning each opponent. Beauty of it would be that by knowing the enemy tarp position, level of structures/walls, we could create really intelligent bot, with many different strategies.

@warclans Yes, this is the holy grail of botting, of course - parsing the network stream that goes between client and server. If you have proof of concept code for that, I'd love to take a look.

AutoIt works great for what I am doing now, which is a simple form of computer learning/image recognition. If you really have what you say you have, then the best approach, IMO, would be to write a wholly new bot in Java native to Android/IOS. Without needing to do the computer learning/image recognition parts, any bot becomes much simpler to write. I'd be happy to take on this project, and work on it collaboratively with you all.

If you start such a project...please, add a "Plugins Engine" at design phase...

@CodeSlinger69 go to my site warclans.com and do a live search :) Also, visit the forum to see the private practice server i have created :)

One thing though, if this turns out to be a serious project, we need to move the conversation to a more private environment

Alright, so I'm registered on your site, warclans. Very nice idea, I'll look into this for my next clan war, and see if I can get any intel on the enemy. Not sure what I am looking for in terms of proof of concept code, however? Perhaps I misunderstood your instructions to do a live search, but I don't see how that applies to this conversation.

But I also agree. This needs to be a private conversation going forward. Your forum?

Yes, you should see the WarClans Lounge forum at the bottom of the list. It is private

cydin commented

hi @CodeSlinger69 1st off all thanks for sharing this wonderful bot, its working great on my TH8, btw can i suggest some ? if u can make end battler when no resource found or end battle within times its will be more great, cos sometimes when i attk ppl all troops already deployed and the timer need to be over to able to end battle. thanks again for you effort and may GOD bless u

Thanks for the kind words, cydin. This has been discussed before a couple of times, but I'll summarize how the bot decides when it is time to end a raid:

  1. If a BK or AQ has been deployed, then the bot will not end the raid early. The thinking here is that these are strong troops, and very well might end up collecting loot all the way through the full 3 minutes of the raid.
  2. If neither the BK or AQ has been deployed, then bot will end the raid 30 seconds after the available loot stops changing. The assumption here is that all troops have been destroyed.

How do you suggest that I change this logic? I think its scenario #1 that you are commenting about, in which case, maybe I could add a check for available loot, and once that drops to 0/0/0 for gold/elix/dark, then end the raid, even if BK or AQ has been deployed?

Just stumbled on that: https://github.com/clanner/cocdp/wiki/Bitmaps.
It could help for your image recognition bmps.

cydin commented

@CodeSlinger69 thanks bro for the fast reply, i think maybe u can make like gamebot they use timer that we can input, if no resource change between X seconds then end battle even the troops or BK/AQ not finished they attack, thanks again, this is just suggestion and im sry if this has been discuss before

That's a good idea, cydin, I'll start a new thread for this. I can add a setting in the .ini file for this. I like this idea, and the code is not all that hard to implement.

Very cool site you got there Warclans, seems like a few people have found
this gem of a bot instead\or with the other ones. I am now making my own
bot for another game Korean Legion of Heroes. The global version is so far
behind the Korean one. I made an English patch for the game already now
time to make a bot for the game. If interested in seeing game/patch you can
check out my page
https://docs.google.com/document/d/1uQRkgcLaT9dAUshJV03xhwUYmysW04_MhkoZpGSrIw8/
Both Andy and Bluestacks needs to be changed a bit in order to run the
game, DuOS runs without any mods

On Mon, Sep 7, 2015 at 1:57 PM, WarClans notifications@github.com wrote:

@CodeSlinger69 https://github.com/CodeSlinger69 go to my site
warclans.com and do a live search :) Also, visit the forum to see the
private practice server i have created :)


Reply to this email directly or view it on GitHub
#22 (comment)
.

Any way to export war stats? attacker/defender/stars/percent/time?

Hi folks - haven't checked in for a few weeks, the bot is stable, and I am saving my energy for the big ClashCon game update in 12 days. I am sure I will have a ton of work to do on the bot for that client update.

Trex, no I don't track any kind of stats, other than what you see in the gui. Loot won is also kind of tracked in the log file as well, although it is not done very well. It just was not a focus of mine.

@CodeSlinger69 is there a way to not dump all your troops when you are sniping th's?

trex,

It dumps in waves. If the TH goes down, then the bot will stop dumping troops. In other words, it will keep trying to get the TH until it runs out of troops. There is a 10 second pause between waves of troops, if I recall correctly.

@CodeSlinger69 I really like your bot. With the mouse on it is peaceful to watch. I am learning how to use Autoit because I want to try to use it to get clan war data. Your code is clean and well organized and shows good planning. It makes it learning easy.
I have had some questions but stuck with them and figured them out. It looks like your scraper code can be modified to read other text, and I am making progress. Anyhow thanks for sharing it.

Thanks, dddddd, I appreciate the feedback, and I am glad you are enjoying the bot! The best way to learn how to code is always to look at what other people have done.

And yes, often times I'll just watch the bot moving the mouse around and clicking here and there...peaceful, as you say :)

Whats the best way to farm de?

The bot used to have a "Zap DE" function, but SuperCell took that ability away from us. Now, I just let the bot collect DE as it goes along its regular farming business. I've been able to get my heros up to AQ 37 and BK 32 just by doing that.

Damn! What values do you use for each and what troop comp?

I'm @ TH9 (with baloon 6 & minion 4)
Playing in silver 3 league.

I set Gold = 0, Elixir = 0, DE = 1800, TH <= 8, Loonian attack.
I get DE steadily with that.

Nice, thanks chris.

I'm TH10 and using barch, gold 100,000, elix 100,000, dark 0, th<=10, ignore storages. I also set dump cups > 2100 to stay in the crystal 3 league.

sweetness, thanks for the info peeps!

Hi CodeSlinger69,
How did you come up with the array values in CharMaps.au3? Did you do it by hand or is there a tool that can compare all the letters in a font to find the distinct pixels?

I am working on writing a tool to scrape the war data out for statistics for my clan, but I am finding that progress is much slower than expected.

I think I only need to read numbers of several fonts and the letters and numbers in the clan tag, so it is possible by hand if I know the methodology, but if there were a tool I am certain it would be handy to have later too. Player names and clan names have so many variations that I plan to save an image of those regions, then use imagecompare.dll to match names.

Finally, is there a better place where I can ask you some code related questions?

Hey dddddd,

There is no tool. However, if you set "Scraper Debug=True" in the .ini file, you can see the output that the engine generates when it is trying to recognize characters. When something changes, like in a client update, I'll turn on this debug to see what is happening, then adjust the entries in CharMaps.au3 as needed. So in effect, that is the only tool I have.

However, the engine/algorithm to interpret characters from pixels is kind of complicated. I've done it a number of times for other bots that I have written, so it's been refined over time and kind of burned into my brain. Explaining how it works would take quite a bit of time, unfortunately.

I don't have a good place other than this issue forum for questions, but if you want to open a new issue thread to talk programming, I'd be happy to keep it open for as long as needed to do some Q&A.

I just created a new Wiki page here with what will eventually become suggested settings at each town hall level.

https://github.com/CodeSlinger69/ClAsHbOt/wiki/Settings

My TH9 Settings for Gold & Elixir
th9 settings

Hi CodeSlinger69. I created an issue on my own project, because I don't know how to create one here. ddddddclash/Clash-Recorder#1

I just posted my first question. Thanks.

Hi CodeSlinger69!
There seems to be problem for the bot to find the townhall in Auto Snipe when the townhall is right at the edge in the middle top or bottom.
Is there anything to change in the ini file to help the script find the townhall better?

jj, this is an unfortunate artifact of my decision to keep the bluestacks screen in standard cell phone resolution. Buildings at the very north or very south corner are sometimes not able to be "seen" by the bot as they tend to get obscured by other on-screen elements, usually text.

There is no solution for this other than to re-work the screen resolution to be square, so no scrolling is required. Unfortunately, this would require a massive change in logic and updating all the images and region definitions.

Interestingly, I'm expecting the November/December update is going to require a massive update of everything anyway, so I am considering doing just that as part of adjusting the bot. I've concluded that SC doesn't care about bots in the slightest, to the small stealth advantages of being at a normal cell phone size screen are outweighed by issues such as the one you mention.

Stay tuned on this - I'll update the other Issue I started to track the Nov/Dec update once we get a view into how significant the changes are going to be.

jjoocc, you could try to remove some on-screen-text modifying the texts.csv file.
Extract it from the apk, decode it using: https://github.com/clanner/cocdp/wiki/Csv%20Files
Once it's a "text" file, you can just search for the text appearing over the townhall and blank it.

At the end, place your modified csv file inside /data/data/com.supercell.clashofclans/update/csv

Now you won't have these texts anymore while scouting/attacking and the imgsearch function won't be fooled so much.

Here's an example.
From the freshly decoded texts.csv you will find:

 $ grep \"TID_PLACEMENT_HINT\" 7.200.19/csv/texts.csv.new
577:"TID_PLACEMENT_HINT","Tap or press and hold to deploy troops","Touchez ou appuyez pour déployer vos troupes.","Antippen oder gedrückt halten, um Truppen einzusetzen","Toca para desplegar una unidad o mantén para desplegar varias.","Tocca o premi e tieni premuto per schierare le truppe","Tik of houd ingedrukt om troepen in te zetten","Trykk eller trykk og hold for å utplassere soldater","Toque ou mantenha pressionado para mobilizar tropas","Birlikleri konuşlandırmak için dokun ya da bas ve basılı tut","タップか長押しでユニットを配置できます","点击或按住屏幕可以派出军队","유닛을 투입하려면 탭하거나 길게 누르세요.","Коснитесь или нажмите и удерживайте, чтобы развернуть войска.","انقر او اضغط باستمرار لنشر القوات","點擊或按住不放可以派出部隊"

Now, simply open the file with a text editor and modify such line like:

"TID_PLACEMENT_HINT","","Touchez ou appuyez pour déployer vos troupes.","Antippen oder gedrückt halten, um Truppen einzusetzen","Toca para desplegar una unidad o mantén para desplegar varias.","Tocca o premi e tieni premuto per schierare le truppe","Tik of houd ingedrukt om troepen in te zetten","Trykk eller trykk og hold for å utplassere soldater","Toque ou mantenha pressionado para mobilizar tropas","Birlikleri konuşlandırmak için dokun ya da bas ve basılı tut","タップか長押しでユニットを配置できます","点击或按住屏幕可以派出军队","유닛을 투입하려면 탭하거나 길게 누르세요.","Коснитесь или нажмите и удерживайте, чтобы развернуть войска.","انقر او اضغط باستمرار لنشر القوات","點擊或按住不放可以派出部隊"

Now, if you place the modified file (no need to encode it back) in the update/csv directory and your ingame language is english, you won't see the "PLACEMENT_HINT" text anymore, just an empty string.

Nice, rumbla! I was totally unaware of this hack. Going to do it now :)

Edit: You don't need unix/lzma to do this. Once you hex edit and add the 4 null bytes, you can open the archive with 7Zip just fine.

Edit 2: I've added a modified texts,csv file to the project, in the Advanced folder. If any of you want to use this hack from rumbla, so you don't have to go through the whole apk, hex edit, uncompress deal.

I'm not sure you "can" host a modified csv file.
The cocdp project was asked to remove them, if I remember correctly.

On a side note, that string is just one of those you want to remove.

You could add some spaces after the s of seconds to move the timer more to the left (skewing all the timers tho). Remove the "Battle ends in:" yellow text...and others.

60 TID_TIME_SECS "s"
61 TID_BATTLE_TIME_TITLE "Battle ends in:"
67 TID_INVALID_PLACEMENT "You cannot deploy troops on the red area!"
68 TID_ALL_TROOPS_USED "All forces deployed"
69 TID_OTHER_TROOP_LEFT "Select a different unit"
240 TID_SHIELD_ACTIVATED "Opponent's shield activated for <hours> hours"
310 TID_BATTLE_START_TIME "Battle starts in:"
577 TID_PLACEMENT_HINT "Tap or press and hold to deploy troops"
885 TID_CONFIRM_WORD "CONFIRM"
1419 TID_HERO_ABILITY_USED "You have used the ability already!"

This is what I usually remove.
Some of these are red texts warnings appearing mid-screen.

I also usually mod the client_globals.csv to start the game zoomed out.

93 INITIAL_ZOOM_TABLET ,90,,,
94 INITIAL_ZOOM_PHONE_WIDESCREEN ,100,,,
95 INITIAL_ZOOM_PHONE ,100,,,

One more modification is using LowGFX graphics and no_wall_animation, to speed up the game a bit. This might disrupt ImgSearch tho as the textures change.
The value here should be the same as ro.product.model inside build.prop file.

ANDROID_LOW_GFX_DEVICES ,,,,,"Lenovo TAB 2 A10-70F",

104 WALL_ANIMATE_CYCLE ,45,,,
105 WALL_ANIMATE_CYCLE_LOW_END ,90,,,

These go alogside with logic/traps.csv and logic/buildings.csv modifications to uncover traps.

Great info, thanks Rumbla. For now, I'll leave the hosted csv file out there, and if there are complaints then I'll remove it.

Those are all very interesting hacks, for sure, I might play around with them later. The biggest problem that ClAsHbOt has right now is the detection of game elements in the far north and far south corners, prior to the start of a raid. Removal of the "Tap or press and hold to deploy troops" text helps with the north corner, but the south corner is still going to be obscured by the troops bar. I'll observe closely over the next couple days and see whether modifying the "Battle starts in XX s" message would further help with the north corner.

Once the raid is underway, the on-screen text doesn't affect the bot at all, so I'll leave those alone for now.

All that said, I'm still considering a different approach once the Nov/Dec update comes out. Moving to a square screen would fix most of the pre-raid image search issues, I think.

Thanks CodeSlinger69 and rumbla!
I will try the remove text hack.
One issue the bot that I have is that when coc crash/reload/outofsync the bot doesnt zoom out as it should so there for not working.
The zoom hack from rumbla might solve that though, just think it would be nice if the bot check if it has the correct zoom level.

jj, the bot will eventually reset the zoom after a crash. It periodically checks to see where it is and what it is doing - it if gets "confused" and can't figure out what is going on, it will try to reset to a known state. I've not seen it get stuck in an unknown state for a long time now.

I had problem a few days back when the bot was running over night. The match windows was zoomed in so the bot just clicked next until all money was gone.

I've never seen that before, jj. If you can reproduce the problem, open up a new thread please, and we will try to resolve it.

@rumbla , how do you modify the APK on BS, to replace the csv files? I used the APK editor app - and the trick works but for some reason I can't get the Google Sign in to work.

Is there an other way to do that?

@chrishubert
I think you need to somehow sign the newly created/modified apk.
I don't know how you you do that...never had the need to do that, really.

As a workaround, to be able to use these csv files so the bot can do its thing in a better way, with your rooted BlueStacks, head to /data/data/com.supercell.clashofclans/update and place the modified csv files there, under the right directory, with the right owner/permissions.
It's imperative that the "Clash of Clans" user can read the files there (and write too, so Supercell can send you patches and overwrite them, with new&unmodified files).

That directory is where Supercell uploads its "patches".
Most of the times these patches are just some changed value in a csv file.
During Halloween update, for example, the patch consisted of a new env.sc file with the "Cauldron" texture (and probably some other, like the bushes and mushrooms) and some changes to logic/obstacles.csv to account for that.

Here's where these files go:

update/csv/client_globals.csv
update/csv/texts.csv
update/logic/traps.csv
update/logic/buildings.csv

You can get the right path for each file directly from the apk file, under the assets directory.
Keep in mind that supercell uploads "compressed" csv only, but the game itself can read "decompressed" csv files too.
Different story for the sc (texture) files. those need to be compressed.

@rumbla , I indeed miserably failed at recompiling properly, working with the update folder is way cleaner.

  1. Root Bluestack with KingRoot,
  2. Move the csv files to the BS shared folder
  3. then move the csv files with ES explorer to the update folder

I still need to find the right parameters for traps and building - but it's definitely fun to play with 🍭
Thanks for the explanation!

Traps are inside traps.csv, while teslas are buildings!

To uncover them, changing the "ExportNameTriggered" texture should be enough.
If you go deeper and discover some more...share it!

Anyone excited about the Dec 10th update? I am dreading the work to update the bot, but looking forward to botting my way through TH11.

BTW, I've updated the client update issue with all sneak peek information, and any impacts to the bot that I can think of. If any of you have thoughts on the matter, feel free to add to this thread: #29

Lot's of new things coming. Sad to see sniping not being an option anymore, was nice to climb fast if needed.
I have a request if possible, a wait for Hero button, so it doesnt attack without atleast one hero available.

I like the idea, jjoocc, about waiting for heros, I'm just not sure how to implement it. You would have to detect whether a hero is sleeping or walking around on the main screen. This would be difficult to do with a high degree of certainty in my opinion. Can you think of any other ways to achieve this?

Can't you just take a screenshot of the first army overview screen and see if there is any Hero available?

Duh. Yes, this can be determined from the Army Overview screen. Create a new issue, please, jjoocc, as I will likely not look at this until well after the update. If your idea is left in this thread here I'm sure it will get lost.

And there's the update live.
Will the new bot be ready by tomorrow. ;-)

I found that a GiBarch strategy with 12-16 giants and 4-8 wallbreakers is a good strategy for farming after the new update. I am however farming in crystal 1, so I also rely on the bonus for good loot, so a big win is needed.

Im having an issue with clashbot, when i start it and turn auto raid on it sits on queue training

Gpuzz commented

Hello CodeSlinger69 is there some way i can contact with you?

Theone: need more info to help out. Screen shots (cleansed), debug logs, etc. Open up a new issue, please.

Gpuzz: We can talk here? If not, put your email here, obfuscated [someone (at) somewhere (dot) c o m ], and I'll email you.

Gpuzz commented

[gpuzz30 (at) gmail (dot) c o m]

Thank you!

Hey codeslinger,
I have been using the bot for about a week now and I'm running into a small issue. Everything runs correctly but 95% of the time the bot does not detect a TH under 7 in autoraid. Right now I'm upgrading to TH6 with about 850 cups. I usually end in the positive numbers but just seems like a small bug.

UPDATE 1/26 - Figured out what the problem was. It was failing the first check on the resources. This is because I had a value of 0 in the Dark Elixer spot and if it didnt find any it didnt report anything, just a blank space. The workaround is to leave that spot blank and then it will pass the resource test before moving on to the TH.

Upgraded AutoIT recently to 3.3.14.2 only system change that I know of. Suddenly unable to recognize Find a Match button.

1/27/2016 09:58:15 DLLLoad() ImageMatch.dll Loaded
1/27/2016 09:58:16 StartBlueStacks() pid=3752
1/27/2016 09:58:16 StartBlueStacks() hWnd: 000C0582
1/27/2016 09:58:16 StartBlueStacks() Control hWnd: 00070592
1/27/2016 09:58:16 InitScraper() Background scraping enabled
1/27/2016 09:58:16 AutoIt Version: 3.3.14.2
1/27/2016 09:58:16 Setting Mouse Deploy Troop Click Delay = 60
1/27/2016 09:58:16 Setting Mouse Donate Troop Click Delay = 250
1/27/2016 09:58:16 Setting AutoRaid End Delay = 0
1/27/2016 09:58:16 Setting AutoSnipe Notify Only = False
1/27/2016 09:58:16 Setting TH Snipe Max Distance From Corner = 90
1/27/2016 09:58:16 Setting Defense Farm Offline Time = 20:00
1/27/2016 09:58:16 Setting Interval Online Check = 15000
1/27/2016 09:58:16 Setting Interval Collect Loot = 180000
1/27/2016 09:58:16 Setting Interval Troop Training Check = 180000
1/27/2016 09:58:16 Setting Interval Pause Between Nexts = 2500
1/27/2016 09:58:21 Keep Online clicked
1/27/2016 09:58:21 Collect Loot clicked
1/27/2016 09:58:22 Auto Raid clicked
1/27/2016 09:58:24 CollectLoot() Found 2 collectors, clicking
1/27/2016 09:58:26 DumpCups() Dumping cups, current=986, threshold=850
1/27/2016 09:58:26 AutoRaidFindMatch() Click Attack button
1/27/2016 09:58:36 AutoRaidFindMatch() Find Match failed - timeout waiting for Find a Match button
1/27/2016 09:58:37 ResetToCoCMainScreen() On Unknown Screen - doing nothing
1/27/2016 09:58:37 AutoQueueTroops()
1/27/2016 09:58:37 ResetToCoCMainScreen() On Unknown Screen - doing nothing
1/27/2016 09:58:37 AutoQueueTroops() Not on main screen, exiting
1/27/2016 09:58:39 Auto Begin: Gold:1597277 Elix:4688543 Dark:32779 Cups:986
1/27/2016 09:58:41 DumpCups() Error, not on Clash main screen
1/27/2016 09:58:41 ResetToCoCMainScreen() On Unknown Screen - doing nothing
1/27/2016 09:58:41 AutoQueueTroops()
1/27/2016 09:58:42 ResetToCoCMainScreen() On Unknown Screen - doing nothing
1/27/2016 09:58:42 AutoQueueTroops() Not on main screen, exiting
1/27/2016 09:58:42 Close clicked

Storm,

Sorry about that. If you have a shield,the Find Match button is slightly different. I meant to update that last night before I made the commit, but I was never able to get a shield, and then forgot about it. I finally got the shield and fixed it in this commit: 5e70d09

Hah, figured it was something on my end, happy to "help".

Hey CodeSlinger69 ... this is good stuff. I've been using it at TH10 for almost 2 weeks, but am now seeing the same theonetoday had --- totally stopped working ... stuck at "queue training". I've grabbed and compiled the latest build but same thing. I actually just noticed a whole bunch of "UnknownFrameXXXX.bmp" images that are all black. GDI issue maybe? Let me know what you need -- thx.

Hiya cb0ttr, glad you've found my bot helpful. This is likely due to the new background mode that I've implemented, see this issue thread: #43 Black images are a key indicator of the background mode not working.

I try to programmatically determine if background mode is not going to work correctly, but maybe your setup is somehow different. Can you tell me more about how you are running the bot? For example, I run BlueStacks in both a standard Win 7 environment, but also sometimes in a VMWare VM running a Win 7 guest. In the VM, the background mode does not work at all, and the bot detects this. It may requires some tuning over time to get this detection working correctly with all the various setups that people might have.

In the meantime a workaround as described in the thread I linked is to set "Use Background Mode=False" in the .ini file, to force the old way of screen scraping.

yeah - win7 VM -- and setting "Use Background Mode=Fase" worked. thanks.

I am running this on my regular Windows 10 machine and Use Background Mode=False did work to keep it online, but now it crashes often. I have attached a picture of some of the crashes.

clashbot
screenshot_20160129-133435
screenshot_20160130-062303

dedren - friendly suggestion : you might want to think about sanitizing those images

Uh oh, I thought I had. What is in there that I missed?

If you guys are keeping up with every one of my commits, you are certainly living on the bleeding edge. I put out official "releases" every once in a while when the bot is stable to my satisfaction. We are in a period of instability right now, as I am making the various changes that I have detailed in other threads.

But bear with me, I run this bot every day 24x7 on two separate CoC accounts, a TH11 and a TH8. I am very motivated to get this stable, and I think I am pretty close now. Tonight's commit has been running quite well for 5 hours now on both accounts. 191a78c

If you do get crashes, please include the log. Also please try to reproduce the error. Most of these errors are reproducible, and with steps on how to make the error happen, I have a much better chance of diagnosing the problem. Screen shots don't do much to help me fix the problem, unfortunately.

I will boot up my Win10 VM and run the bot there for a while, however, just in case that horrific operating system causes some peculiarities with the bot.

Love the bleeding edge 😁. Understood about the screenshots.

I ran for about 24 hours on a Win 10 VM, and had no issues. I'm running the bot with great stability and no errors on both of my accounts. Today's commit (3d835c4) is very minor tweaking. I hope to push an official release in a few days, assuming I encounter no errors, and you all don't find anything tragic for me.

Thanks for being patient.

@dedren -- totally misread your screenshots & mistook the enemy's name for your base name -- they were fine - sorry.

@CodeSlinger69... been running it for a few hours now from this morning's commit and it seems to be stuck at "queue training" after I come back from a break. seems it doesn't auto-zoom out and keeps cycling through the training loop, even though my camps were full. I've just pulled the latest commit and will try again & let you know. Thanks for the work - would love to pick your brain some time on design decisions for the image library and other code stuff =)

*EDIT - may have been my fault on the training loop --- not sure I disabled background mode when i pulled the source from this morning ... working for the past hour

Wicked stable for me the last two days, so I pushed a release tonight: https://github.com/CodeSlinger69/ClAsHbOt/releases/tag/20160201

Next up on my list

  • moving the OCR code to the DLL to gain some performance improvements
  • support for BlueStacks 2.0
  • algorithm to detect weak bases

Just installed the release! I noticed that the 'Collect Loot' option misses some of the resources below the lower half of the screen.

It doesn't miss them all so I tried switching them around to see if the locations were the problem and they were. It is a very specific spot too. Move them two tiles and they work fine. I took a screenshot after running the bot for 30 minutes or so you can see those spots.
point blur_feb022016_003049

Additionally, I have tried it with Background Mode enabled (AutoIt crashes within seconds, but that may be another issue to test) and disabled (the only way to use the bot long enough to test).

I purposely sat in front of my Windows 10 machine and had a couple of Chrome windows open. One running YouTube videos and one typing this.

Bot crash when enable background mode, and mouse got locked(can't move) for a while.

And seems no valuable information in log file.

Win10

Hi all,

Was just wondering if automatically upgrading resources or dumping loot into walls was a feature yet, or if it is in the pipeline? (Sorry if this has already been discussed, but I couldn't find it anywhere in the issues/on this thread/on the wiki)

Cheers!
PS: ClAsHbOt looks amazing! Can't wait to try it out over the weekend :D

dedren, I've seen a couple of crashes too, but only when running in VMWare. I'm running both my accounts under a debugger right now, so the next time it crashes, I'll have some idea of what to fix. As to loot bubble popping; there is a fine line in detecting what to click on and not - those loot bubbles are pretty small. You can try adjusting the $gConfidenceCollectLoot global variable in globals.au3 to something smaller, like 0.94. I've seen the bot eventually get around to popping all the bubbles, however, if you give it time.

leepupu: yes, the bot will lock out keyboard/mouse input into the BS window when it is trying to do something. Don't hover the mouse over BlueStacks while the bot is running and you won't have a problem. These lock out periods are generally very short, except when queueing troops to build, in which case the lock out may be a few seconds.

osguy: No plans for that. This is primarily a bot to help me farm, and I never intended it to play the whole game for me. I just automated the tedious parts of the game.

CodeSlinger69 -- not sure if it's my VM environment (win7x64 2GB) but bot wont run for more than 10-12 hours ... it doesn't crash, but bluestacks is sitting at the home screen with the bot it stuck at the "queue training" screen. What should I be looking for?

Well, I ran the bot for 24 hours on two accounts, for a total of 48 hours running under debugger. I did get one crash that was caught by the debugger, and I fixed my stupid error: ba9b41a

Once fixed though, the bot is remarkably stable for me. If I see any more crashes, I'll run under the debugger again, but for now it looks good.

cb0ttr; I run one of my accounts under a Win 7 x64 VM as well. I have seen the bot get stuck occasionally, but usually that is due to me interfering in some way. Is it getting stuck one one of the Barracks tabs then? The same one every time? Anything interesting in the log that might give a clue?

I'm going to create a new thread: "How to diagnose and report problems". I'll put some more info in there on how to turn on various flags and generate more debug output.

Its quiet in here again. This is good, I think. I'm pretty much done with my performance optimizations, and fairly pleased with the way the bot is running right now. I'm going to attack the two open issues, which are items in the "new features" category. Assessing the strength of a base can really help with farming, especially at TH10+.

If anyone has any "new features" ideas, create an issue for them and we can have a discussion about them. Many of the features in the bot have come from you guys over the last year (wait for heroes, end raid early, reload defenses).

I have been trying to find any clue as to why the AutoIt keeps crashing. Unfortunately even with all the debug methods on it doesn't show anything, so have come to the assumption that it is AutoIt that doesn't like what is going on. Is there a C style DLL involved in this because that is all I could make sense of so far, as seen in the link here: http://stackoverflow.com/questions/27317712/calling-a-c-style-dll-succeeds-and-then-autoit-crashes

If the computer isn't doing anything else the bot can run for as long as the loot chest isn't near the chat arrow. But doing anything on the computer causes AutoIt to crash without reporting anything to the log.

Interesting about the loot chest/chat arrow. I haven't seen my loot chest get too close to the chat arrow, but I can imagine what would happen if it did. This might just be a case where human intervention is required.

As to the DLL, yes this bot uses a C style DLL for image searching and OCR. Source code is here on GitHub if you are curious. If the DLL has an unexpected problem, then AutoIT will crash with no useful information. I use my computer all the time while the bot is running in the background, with no problems. However, it seems that whatever you are doing on the computer is causing something to be sent to the DLL that my code is just not accounting for, thus the crash.

AutoIt protects you from crashes quite a bit - C/C++ does not. Unfortunately, I don't have a massive amount of error handling/valid data checking in the DLL yet. I think I will do this, however. I'll put in valid data checks and log output wherever I can think something might go wrong, or cause problems. I've created a new issue and will post updates here: #51

The DLL isn't too large, so this shouldn't take too long.

Thanks, I've been experiencing the same thing quite a bit on Windows 10. Seems tied to mouse movement, even if the BlueStacks window is on a different screen