Code Monkey home page Code Monkey logo

hqtrivia-automation's Introduction

hqtrivia-automation (WIP)

I vaguely wondered about the HQ trivia game and automating to get an edge in the game since there is nothing stopping you from googling for answers. Why not automate it in effort to learn? Well here's my attempt...

Note using this during live game would break HQ's terms of service. So if you want to play around with it like I did, just take snapshots of the question and use after game. DO NOT USE TO CHEAT!!! Made for educational purposes only!!!

Work Flow

  1. Capture source image either via quicktime player (recommended) or webcam (untested). If using quicktime you can do a movie recording without actually recording. Just hit the drop down arrow by the record button to select iPhone as source (iPhone must be connected by wire).

  2. Multiple OCR engines will attempt to read the text off image. Currently supporting Google Tesseract OCR (free/open source) or Google Vision API (free but requires billing account and has limits). Note that Vision API is generally better.

  3. Text is parsed into question and answers. The answers are then searched wikipedia, google search, multiple dictionaries and synonyms are looked up too. NOTE: More will be added soon. Finally, searches that have more relevancy with the question are scored higher. The answer that scores the highest is shown. NOTE: All of this is done in a multiprocessing pool to speed up results.

  4. Display the results on screen as answers are being looked up.

Installation

Use python 3.6 and take notice of the modules used in the python file. In particular the packages used are...

  • Pillow - Image manipulation
  • numpy - More advanced image manipulation
  • PyObjC - AppleScript for taking screenshot
  • opencv-contrib-python - WebCam for taking screenshot
  • wikipediaapi - Wikipedia searches
  • vocabulary - Dictionary and synonyms searches
  • pytesseract - Google's free/open source OCR (requires seperate installtion)
  • google-cloud-vision - Google's commercial OCR (free also but with limits and additional setup)
  • nltk - local dictionary
  • beautifulsoup4 - parse google searches

Oversimplified steps

  1. Install python 3.6
  2. Install above packages
    • pip3 install -r requirements.txt
  3. For nltk run python3 -m nltk.downloader all

Usage

Simply execute script with the right options...

$ python3 hqtrivia-automation.py -h
usage: hqtrivia-automation.py [-h] [-q | -w | -i INPUT] [-v] [-V]

Automate searching for answers in HQ Trivia

optional arguments:
  -h, --help            show this help message and exit
  -q, --quicktime       Use quicktime to capture source image
  -w, --webcam          Use webcam to capture source image
  -i INPUT, --input INPUT
                        Use image provided instead of capturing
  -v, --verbose         Spit out debug information
  -V, --version         Version of script

NOTE: Have to select -q, -w or use -i

hqtrivia-automation's People

Contributors

jrudow1 avatar natefanaro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.