Closed CodeSlinger69 closed 8 years ago
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.
I still need to find the right parameters for traps and building - but it's definitely fun to play with :lollipop: 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: https://github.com/CodeSlinger69/ClAsHbOt/issues/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
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.
[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: https://github.com/CodeSlinger69/ClAsHbOt/commit/5e70d09e5bd3dcb401fa06cc6a1f76ae6e3a647a
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: https://github.com/CodeSlinger69/ClAsHbOt/issues/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.
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. https://github.com/CodeSlinger69/ClAsHbOt/commit/191a78cb43a05c86c8614a10af237991bd2d1863
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 (https://github.com/CodeSlinger69/ClAsHbOt/commit/3d835c4de74c08553a3a16d02c28e29dc46c4293) 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
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.
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
I forgot to attach my log to my post abovehttps://github.com/CodeSlinger69/ClAsHbOt/issues/22#issuecomment-178395362.
See attached. ClashBotLog.txt
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: https://github.com/CodeSlinger69/ClAsHbOt/commit/ba9b41af5eb92ad1f6c4b0bc208c6be99c21d1ad
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: https://github.com/CodeSlinger69/ClAsHbOt/issues/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
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.