5
\$\begingroup\$

You are from the tiny country of Que-Wopistan. The Que-Wopistonion's are a proud people, and every Que-Wopistonian dreams of making their country proud by representing their country in the Olympics.

You have been given the incredible honor of competing in the 100-meter-dash. You are the nations sole representative, so there is a huge amount of pressure on you to do well. Unfortunately though, Que-Wopistan's training program is awful! Absolutely terrible. You can't work with this, so you decide to train yourself.

You try a few practice runs. On the first run, you make it 0.3 meters forward, and then fall on your face. You are dedicated though, so you get up and try again. This time, you actually go backwards -1.7 meters, before falling on your face again. You try again. And again. And agin. And again, but every time you fall on your face before making even 2 meters forward. You just aren't coordinated enough to run. Or walk. Or even-- not fall on your face.

This is where your programming expertise comes in handy.

The challenge

In case you haven't realized yet, I am talking about the game QWOP. Once you have wasted 60 minutes, mashed your face into the keyboard, and now returned to this page after rage-quitting (don't worry, I did the same thing), here is your challenge. You must write a program that uses simulated key-presses to play the game of QWOP for you. The following actions do not have to be done by your program (you can do them manually yourself)

  1. Opening the web browser and going to the correct page.
  2. Starting and re-starting the game.
  3. Make a screen recording.

Everything else must be automated by your program.

Judging criteria

The winner of this contest will be the program that makes it the farthest. In the unlikely event of a tie (Which will happen if anyone actually makes it 100 meters), the winner will be decided by who made it there quicker. This is not code-golf, byte-count makes no difference.

If your program automatically detects the game being over (the game ends if you fall on your face or make it 100 meters) and exits, you will get a +10 meter bonus.

\$\endgroup\$
  • 3
    \$\begingroup\$ This is basically asking for a tool assisted speedrun of QWOP. Not sure if that's on topic as a programming contest. What stops someone skilled at the game from beating it while recording their keystrokes, then having their code play back those keystrokes hard-coded at the exact times? \$\endgroup\$ – xnor Oct 28 '14 at 19:09
  • 2
    \$\begingroup\$ I don't have the slightest clue how to feed timed keystrokes into a production Flash application, but if you could provide some sample (JS?) code accomplishing this, the challenge sounds worth a try. \$\endgroup\$ – COTO Oct 28 '14 at 19:22
  • \$\begingroup\$ I'd like to do this, but unfortunately I don't have Flash installed (nor would I be able to figure out how to send keystrokes to it, if I did). Is there any way to expose some sort of API to programmatically play QWOP or something? \$\endgroup\$ – Doorknob Oct 28 '14 at 20:54
  • 2
    \$\begingroup\$ Hm, I'm not sure but wouldn't you just need to simulate a low-level keystroke, rather then sending it in to the flash application? \$\endgroup\$ – James Oct 28 '14 at 21:17
  • 2
    \$\begingroup\$ It doesn't seem that hard to make 100 m. After a few tries I got to 78.6 m by only using the 'Q' and 'W' keys (excepting the first couple of seconds). \$\endgroup\$ – feersum Oct 28 '14 at 22:07
9
\$\begingroup\$

AutoHotkey, 100.5 m

finish line

After running the following script, it can be activated by pressing Windows+H (yes, it only works on Windows). It can be stopped by pressing Escape.

#SingleInstance force

Esc::ExitApp

#h::
    Loop,5 {
        Send, {w down}
        Sleep, 300
        Send, {w up}
        Sleep, 300
    }
    Loop,9999 {
        Loop, 23 {
            Send, {q down}
            Sleep, 200
            Send, {q up}
            Sleep, 400
            Send, {w down}
            Sleep, 350
            Send, {w up}
            Sleep, 400
        }
        Loop,6 {
            Send, {w down}
            Sleep, 250
            Send, {w up}
            Sleep, 400
        }   
    }
return

This particular code reached the finish line the first time it was run. I don't want to test it again now, because it takes forever and I can't do anything else while running it (Please comment if you figure out how to send keys to the Flash player without it being in focus). Caveat: At around 30 m, no keys were sent for a few seconds because a Windows pop-up jacked the focus. It was tested in Chrome browser.

When the script reached the obstacle at 50 m, the script somehow jumped over it right away, which may be a lucky and unusual occurrence. As for the time, the game irritatingly does not tell you how long the run took, but it does have a built-in tiebreaker by allowing you to jump as far as possible beyond the finish line at the end.

Also, this game's code does not seem very robust:

bug

Huh?

\$\endgroup\$
  • \$\begingroup\$ AutoHotkey also seems to have the ability to read the color of pixels, so it could potentially be improved by detecting when 50 or 100 m is reached. \$\endgroup\$ – feersum Oct 29 '14 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.