Created
August 8, 2012 06:48
-
-
Save reaaz/3292880 to your computer and use it in GitHub Desktop.
Automated Script to Play Google Basketball Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Small Python/AppleScript to play the Google Doodle Basketball game | |
# at http://www.google.com/doodles/basketball-2012 | |
# Current high score is 36. I'm sure that can be improved with better delay | |
# management. | |
# Directions: load the game in your browser, hit play, and exec the script. | |
import os | |
# Our set of shots: (number of space presses, delay for shot type) | |
shots = [ | |
(20, 0.25), # Closest shot | |
(13, 0.4), # Midrange | |
(14, 0.58), # Three-pointer | |
(12, 0.78), # Deep three-pointer | |
] | |
app = """tell application "Google Chrome" to activate""" | |
for s in shots: | |
app = app + """ | |
repeat %s times | |
tell application "System Events" to key code 49 | |
delay %s | |
end repeat""" % (s[0], s[1]) | |
cmd = "osascript -e '%s'" % app | |
os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment