Using python scripts to play the candy basket game on the google Homepage

Source: Internet
Author: User

There will be a logo game in the new tab of chrome's homepage. Today, we are playing a candy basket to drop the candy. This is google's 15th birthday.

Note: These two days new tags can not see the game, the game address is: http://www.google.com/doodles/googles-15th-birthday

After the start, press the Space key at a certain interval, and the blind man will wave a stick to hit the candy basket, and then drop the candy. After 10 hits, the game is over.



This is my highest score.

The key to hitting a basket is to try your best to reach out of your basket as quickly as possible to get the most out of the candy.

I think that I am not addicted to it. I want to use a program to play the game. In order to reduce manual operations, I don't need to press the Space key with my hands all the time. I wrote a script in python to play the game.

1. Download The autopy https://pypi.python.org/pypi/autopy/2 here. Download my uploaded hitting script to modify it by yourself, mainly to adjust the hitting Interval

Hit the candy basket with the candies. py I wrote. This script is appended to the end.

Usage:

1. Modify the script 2. Execute the script and switch to the chrome browser within 3 seconds 3. 3 seconds later, you will see that it is playing


The key is to adjust the key interval.
The script uses the autopy cross-platform library to call your keys, such as press Space key, A-Z, Shift, Alt, Ctrol and so on, this game only needs to press Space key.

Candies. py

#!/usr/bin/env python"""Play http://www.google.com/doodles/hurdles-2012 .Code based on https://gist.github.com/3287367 . """import timefrom autopy import keydef play():    print '# switch to the candies game in your browser (you have 3 seconds)'    time.sleep(3)    s = time.time()    n=0    while time.time() - s < 15:        n=n+1        ##for _ in range(14):        ##    key.tap(key.K_LEFT)        ##    key.tap(key.K_RIGHT)        key.tap(' ')        if n<4:            time.sleep(0.01*n+0.1)        else:            time.sleep(0.12)#############################################################################if __name__ == "__main__":    play()

Some people say that python can play game plug-ins. This is not a lie, but it may be difficult to do complicated plug-ins.


Speaking of the results, through continuous debugging, my script scored 155 points.

Of course, it's not the above script. It depends on your own debugging.


This is a contest...


The script has scored 170 points.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.