Teach you how to play the [Top Conference] quiz game

Teach you how to play the [Top Conference] quiz game

In the past two days, live quiz apps such as the "Chongding Conference" have suddenly become popular. I have to admire the imagination of Internet companies. So how can programmers play quiz games in different ways? Previously, WeChat's "Jump Jump" game was popular in the circle of friends. Many friends have already written automated scripts to assist. When I saw the quiz game, I immediately thought of using a similar method to write a simple script. I found that a friend had already made a call to Baidu API, so I wrote another one that directly uses the recognition library. The code idea is simple and can be used in various quiz games. Using text recognition plus search can only play a role in assisting decision-making. You can refer to the results and increase the accuracy, but it cannot guarantee full correctness.

For specific code, environment and usage, please click: https://github.com/Skyexu/TopSup

Star ^ ^

Inspired by:

  • WeChat Jump Assistant
  • How do programmers play "Chongding Conference"?

Specific approach

1. Use ADB to take screenshots of your phone

  1. adb shell screencap -p /sdcard/screenshot.png
  2. adb pull /sdcard/screenshot.png .

2.OCR recognizes the title and option text

Use code to intercept the title area and option area respectively, and then perform text recognition

There are two methods for text recognition:

  • Google Tesseract, just install the software, and then mainly use this method
  • Baidu OCR livc, you need to register Baidu API, the number of calls per day is limited

3. Search judgment

Result judgment method

1. Open the browser and search for the problem directly

2. The title + each option is searched through a search engine, and the number of search results is extracted from the web page code

3. Search only with the title, and count the frequency of words in the result page code that contain the options

The following are two example results. It can be seen that the two methods have different results for the following two questions, and different decisions can be made depending on the type of question.

Referenced I Hacked HQ Trivia But Here's How They Can Stop Me

Main code

The main code of the verification idea is to realize screenshot, recognition, and call browser search. It is actually very simple. For details, you can refer to the simple version code in my github library.

  1. def pull_screenshot():
  2. os.system( 'adb shell screencap -p /sdcard/screenshot.png' )
  3. os.system( 'adb pull /sdcard/screenshot.png .' )
  4. pull_screenshot()
  5. img = Image. open ( "./screenshot.png" )
  6. # Cut the title position, the upper left corner coordinates and the lower right corner coordinates, test the resolution yourself
  7. question = img.crop((50, 350, 1000, 560)) # Nut pro1
  8. choices = img.crop((75, 535, 990, 1150))
  9. #region = img.crop((75, 315, 1167, 789)) # iPhone 7P
  10. # tesseract path
  11. pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'  
  12. # Language pack directory
  13. tessdata_dir_config = '--tessdata-dir "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"'  
  14. #lang specifies simplified Chinese
  15. text = pytesseract.image_to_string(question,, config=tessdata_dir_config)
  16. text = text.replace ( "\n" , "" )[2:]
  17. print(text)
  18. webbrowser.open ( 'https://baidu.com/s?wd=' +text )

Summarize

After writing the simple version, I thought about it and realized that it is not as convenient as Hi and Siri. But fortunately, it has accurate recognition and fast query. Later, I added several methods to assist decision making. Text recognition plus search cannot be done completely correctly in this type of game. If you want to achieve complete correctness, you may still have to capture packets? Or store question banks, but this is too time-consuming. With ADB screenshots, I am afraid that all kinds of small assistants can be played. You can use your imagination. Python is really convenient to write small scripts. Next, you can try to process the relationship after text recognition with NLP, and then search for different selection results to increase the accuracy, etc. I don’t want to play anymore. I have to write a paper.

<<:  A front-end programmer's one-month native Android development experience

>>:  Don't want to stop using iCloud? Why not migrate your data to another Apple ID?

Recommend

Create a silky smooth H5 page flip library

background With the popularity of mobile marketin...

How should educational companies acquire customers on Kuaishou?

2019 was a "winter period" for the educ...

Here are the top ten channels for APP promotion effectiveness!

I believe that many students who are responsible ...

00Kb2's small plug-in can remove WeChat blocking!

[[351621]] Needless to say, everyone knows that t...

How much does it cost to develop a nutritional product mini program in Yangquan?

WeChat Mini Program is an application that users ...

Wuwei SEO training: How to improve the weight of the website's internal pages

The most important thing for us to do website opt...

Where can I make a 400 number and what are the ways to do so?

In daily life, you must have seen a ten-digit 400...

How does information flow advertising use 10,000+ tags for precision marketing?

Different from traditional advertising, the bigge...

iOS 15.5 quasi-official version released

The size of this update package is about 5.2G, an...

Do you still remember the text message you left in the corner?

[[141286]] At the end of June, Matti Makonen, a F...

Landing page design tips for the education industry!

With the winter vacation approaching, the educati...