Automatic submitting

Discussion about the puzzle system.
Post Reply
klavierspieler21
Posts: 16
Joined: Fri Jul 13, 2007 12:21 am
Location: Waterloo

Automatic submitting

Post by klavierspieler21 »

Hi,

I'm new to programming. In fact I just took my first introductory class this semester in Scheme at U. of Waterloo.

I wrote a small quasi brute force for Runaway Robot, but I don't know how to write something that will automatically get and submit my answers.

Anybody can give me an example/teach me in Python or Scheme?

Thanks
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

check out the bricolage forum. There is a sample program posted in python. If you prefer java, you can find one in mortal coil. Maybe some other languages can be found, if you use the search function of the forum.
klavierspieler21
Posts: 16
Joined: Fri Jul 13, 2007 12:21 am
Location: Waterloo

Post by klavierspieler21 »

yeah i tried going through the python script, but i couldn't figure out how to extract the "get and submit" part of it.

can someone be kind enough to explain the gist of it?
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

If you don't care about error handling and things like cookies, then it's pretty simple:

Code: Select all

import urllib2

# Fetch a page
page = urllib2.urlopen('http//www.hacker.org/...').read()

# Oops, needed to provide login details
page = urllib2.urlopen("http://www.hacker.org/...?name=klavierspiel21&password=XXX").read()
# or use the "spw" system to avoid sending your password all the time

# Same for submitting solutions:
page = urllib2.urlopen("http://www.hacker.org/...?x=5&y=2&path=ULULDLURDRD").read()
In each case, "page" will be a string containing all the content sent back by the server. You'll need to parse it a bit to extract the FlashVars strings.

For later levels you sometimes need to submit with POST rather than GET as above, but GET will be fine initially.
klavierspieler21
Posts: 16
Joined: Fri Jul 13, 2007 12:21 am
Location: Waterloo

Post by klavierspieler21 »

wow thanks o.O
i'm learning so much here its incredible...
i'll play around to get familiar with this..
right now i'm working on an efficient Runaway algorithm (still in scheme though...). if its actually as good as i'm thinking it is, it should get me up to 513 like all of you up there :P

oh and btw this site is amazing.
cheers to everyone
Post Reply