Achieve "national dream home" game in receipt automatically receive gold with LabVIEW

The last few weeks, a very popular mobile game, called "dream home country." I play one or two days on the phone and found two problems:

1. Receipt received gold too boring, just slide your finger on fixed routes, while on its hands

2. how to catch people catch up fast chips (of course, requires a certain strategy)

I just play this game, but also ranked first in friends, but fell into the third, is really over, but the young thirty-four days. . .

 

Recent research just inside the LabVIEW Vision on things, just want to be able to write a receipt automatically collect gold coins program, can let the program up and running before going to sleep at night, get up in the morning when you can gain a lot of red envelopes. Just do it!

framework design

The whole idea is to use image recognition algorithms to identify what goods train above, and then transporting the goods to the corresponding building there.

After the study of the shots and found that the game has the following characteristics:

1. Every time the train stays for up to about 90s, and up to three for each shipment of goods, quantity of goods each generally in less than five

2. Small train above the cargo will randomly drop some incentive (Later, I told my colleagues I actually have a strategy, but I do not bother to consider a)

3. Click on the building can harvest gold, and will randomly drop reward (red, blue star coins, contribution)

 

Based on the above three points, we can design the framework.

1. First of all have been running a while loop, so as to keep the automatic collection of goods received gold here while loop is set to run a loop 4s

2. Then while loop which have several modules: image acquisition, target recognition, handling cargo (yield gold).

 

Image acquisition

Here we use the BlueStacks emulator running "dream home country" in this game, because there is no real machine, but it also supports ADB, it will be very convenient.

At first I thought that the Android emulator open on your desktop, and then use LabVIEW to capture the entire desktop, then that part of the game to pull out the screenshot. So I also tried to achieve, but the effect is not good, because to pull out of the game pattern portions, and resolution Android emulator is not the same, that is to say the size of the display of the simulator to do the compression.

So I will simply direct use of ADB shots, cut finished map spread PC, and then do analysis. ADB screenshot command reference this post: https://www.cnblogs.com/guoguojiang/p/10347211.html

1. Theme command sent by ADB (adb shell screencap -p /sdcard/screen.png)

2. ADB command transmitted on the theme PC (adb pull /sdcard/screen.png)

  

3. Vision in the local open API to png file, and prepare to pass the subsequent image processing section. The entire code is like this:

  

4. Delete the picture just pass over

Identify the target

In the vision of LabVIEW toolkit, there is a special API for pattern matching, then I chose here before I used a template that matches the relevant API. API does not go into detail about this, because the vision kit also comes with an example, it is easy to use them, the simplest procedure is to first learn to use the template, and then to identify the target figure, there are no template information.

 1. First cut different templates, all the features of the pattern portion taken out, saved as a png file. It should be noted here that some features may randomly appear on any of the three sections of the cabin of a carriage, different compartments of the template pattern is slightly different, need more than a few shots in different compartments of the map.

  

2. The whole algorithm process is to first load all of the template (template because the load + learn very slowly, so the first load is good), and then do the geometric template matching for image acquisition, if the group found a template, put it to slide corresponding building there. If the template is not found, then collect the building where the gold coins.

Here are some ways to the optimization algorithm, for example, the ROI is set to a small area around the train, this range will be greatly reduced neatly. By this matching algorithm, it is possible to find the coordinates of the goods, transporting the goods to pass behind the module. Code figure below, enter a dozen sheets of drawing templates, and our game screenshots; output is the index of the detected position of goods and cargo, which is to facilitate the building to find the coordinates of the corresponding (building coordinate achieve better storage , and the index may be considered to be one to one hash-map). Here that score 900 points or more to the template is detected (between 0-1000 matching score, the higher the higher the degree of match).

  

Cargo handling (collection of gold coins)

 Cargo handling is very simple, since the goods to get the xy coordinates, and the corresponding coordinates xy building, then a command similar to the following would be the ADB.

adb shell input swipe 250 250 300 300

 

In the absence of the goods found, you can go to collect gold coins, you can also send ADB commands, but requires continuous charge gold nine buildings, you can use a command queue ADB, slipped from ninth the first building, then back to the first.

 

result

The results can look this video, in fact, ADB command run up is very slow, are greater than the loop rate I set the (4S), but would like it to be so.

https://v.youku.com/v_show/id_XNDQwNDY2Mzg0MA==.html?spm=a2hzp.8244740.0.0

A night would be able to do 100 red envelope, presumably defeated contribution really can not think there is a small train supply quota. . .

 

 

 Spread

1. Because ran two nights there will be 200 + a red envelope, red envelopes to open the manual too tired, simply made a red envelope of automatic opening program. The idea is very simple, is to use ADB commands simulate the timing of clicks, but also support a variety of red, open book, so save a lot of effort.

 

2. Because the shots a lot of trouble, so it can be easy to write a small tool to draw deposit box template.

 

 

 If there are new demands after it, and then continue to the new features it. Code is badly written, that is, it can make do, please share.

Guess you like

Origin www.cnblogs.com/sonwendi/p/11716667.html