Refresh Cannon Bot

I stumbled on Refresh Cannon today. The entire “game” (it’s extremely simple) is controlled by refreshing your browser. The goal is to use a cannon to hit a house on the other side of the screen. The first refresh starts increasing the cannon’s angle, the second refresh locks-in the angle and begins increasing the power. The final refresh locks-in the power and fires.

lose

The angle goes from 0-90º over 10 seconds, so half a second is the difference between 75º and 79.5º. Since the novelty of refreshing your browser gets old extremely quickly, I wrote a Ruby script to give myself the high score. The script just tries a bunch of angles and powers that are likely to result in a hit. I have no clue how to do image processing in Ruby, so I just checked the HTTP response size. The “Win!” image is usually about 1k larger than the “Miss!” image.

win1

Unfortunately, it looks like somebody else wrote their own script and started running it several hours before I discovered the blog post. I’ll have to settle with second place. Update: I am now in 1st place.

I didn’t put much effort into the angle/power guessing, since latency screws up any attempt to methodically carpet bomb the map. I account for constant latency, but jitter is bad enough that trying the same times between HTTP requests will cause the cannonball to land only in the general area intended.

Here’s my script, in case you’re curious. Yes yes, I know it’s hideous.

If I felt like wasting more than an hour on this, it could be improved by:

  • Storing success rates of angle/power pairs, then trying the most successful pairs first.
  • Registering multiple IPs to the same username, allowing multiple copies of the bot to increase a single user’s score.
  • Using image processing and OCR to find the difference between the attempted angle/power and the actual angle/power.

5 Comments

  1. Hank wrote:

    And I thought I was a big time waster. :-)

    See if you can get $5 deposited in a PayPal account for each download. There’s bound to be ten people in the world that would pay for this just so they could get high score.

    I mean, since you have so much time on your hands. ;-)

    Wednesday, May 6, 2009 at 13:15 | Permalink
  2. By the way, I think I found your competition: http://twitter.com/probablycorey/status/1712873256

    Thursday, May 7, 2009 at 02:00 | Permalink
  3. Geoff Greer wrote:

    Yeah, I found him yesterday and gloated: http://twitter.com/ggreer/status/1723570459

    Thursday, May 7, 2009 at 10:20 | Permalink
  4. Chris Deotte wrote:

    Hey Geoff, you inspired me to write a program also. I wrote mine in php and used image processing, statistical analysis, and many other optimizations. My robot, named Black Powder, is currently hitting over 70 shots per hour. Check out its progress here: http://banach.ucsd.edu/RefreshCannon/?show=1

    Tuesday, May 26, 2009 at 06:01 | Permalink
  5. Geoff Greer wrote:

    That is absolutely ridiculous…

    …ly cool.

    Tuesday, May 26, 2009 at 13:49 | Permalink

One Trackback/Pingback

  1. Refresh Cannon Bot | ClassicalCode on Thursday, May 7, 2009 at 00:22

    [...] Boring Programming Stuff gave me the biggest compliment a programmer could recieve. He wrote a program to use my program! As he points out in his post, it seems pretty clear that he is not the only one. If there is [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*