Closed CodeSlinger69 closed 8 years ago
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:
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 https://github.com/CodeSlinger69/ClAsHbOt/issues/22#issuecomment-129937972 .
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 :smile:
:+1: for the opensource dll. Something noone else has done, till now.
rumbla:
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
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:
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.
@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 https://github.com/CodeSlinger69/ClAsHbOt/issues/22#issuecomment-138368581 .
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.
My TH9 Settings for Gold & Elixir
Hi CodeSlinger69. I created an issue on my own project, because I don't know how to create one here. https://github.com/ddddddclash/Clash-Recorder/issues/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?
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.