problem in automating the puzzle

This forum is for discussions related to the Runaway Robot puzzle
Post Reply
User avatar
bodjo
Posts: 37
Joined: Sat Feb 26, 2011 9:27 am
Location: tunisia

problem in automating the puzzle

Post by bodjo »

hi guys i have already create a python solver for this puzzle but the only problem is i don't know how to get values from variables in the site
i think i need some help :roll:
uws8505
Posts: 32
Joined: Sun Jan 23, 2011 8:57 pm

Post by uws8505 »

Simply pick a simple level (possibly level 0) and take a look into its source code.
You can find everything about the puzzle shown on the page in the source code.
Also, don't try to figure out the line number where the problem values, but rather a keyword where the problem values are in the same line. This way, the program is guaranteed to obtain the problem values, and the code is also quite simple in Python.

Personally I did beat this with C++ when I didn't know Python, but copy-pasting the problem every time to notepad was really a pain...
User avatar
bodjo
Posts: 37
Joined: Sat Feb 26, 2011 9:27 am
Location: tunisia

Post by bodjo »

yes but i want from the solver to automaticly do that
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

You can use various string manipulation functions to spot the variables automatically. Import the page, cut out the bits you don't need, parse the bits that are left.
There is no spoon.
User avatar
bodjo
Posts: 37
Joined: Sat Feb 26, 2011 9:27 am
Location: tunisia

Post by bodjo »

good idea :lol:
thank you
virus171
Posts: 4
Joined: Sat Jul 10, 2010 1:54 pm
Location: Australia

Post by virus171 »

Hi guys. With regards to automation, I have been able to extract all of the useful information from the source code, but when it submits the answer, I am always told that my answer sucked. I check my solution with the string representing the layout of the map obtained from the source code and find no problem.

Just wondering what I am doing wrong and how to fix it
MrTerry
Posts: 34
Joined: Tue Jan 26, 2010 11:44 am

Post by MrTerry »

well could be anything.....
since it tolds u that ur solution sucked means ur locked in.... so there must be something within the solution itself....could u show an example url u would use ?
Runaway Robot LvL 452
path: DDDRDRDDRRDDRRDRRRDDRRRRDDDRRDDDRRDRDRDRDRRRRRDRRDRRRRRDDRRDDDDRDRRRDRRDDRDRDRRRRRDRDDDRDDRDRRRRDDDDDDRRRRRRR

boom at 1 1
your solution sucked

Oo wtf?
megabreit
Posts: 141
Joined: Sat Jan 03, 2009 3:33 pm

Post by megabreit »

You need to save the session cookie and use it when posting the result!
Otherwise you get a different level each time... and the solution for the old level sux all time :-)
virus171
Posts: 4
Joined: Sat Jul 10, 2010 1:54 pm
Location: Australia

Post by virus171 »

Thanks for the replies
Would you be able to tell me how i would do that in python? I don't have very much (any) experience in doing this sort of thing. I did a search, but I'm not exactly sure what's needed.
megabreit
Posts: 141
Joined: Sat Jan 03, 2009 3:33 pm

Post by megabreit »

I can tell you how this works in perl:

Code: Select all

my $request = HTTP::Request->new(GET => "http://www.hacker.org/runaway/index.php?name=$user&password=$password");
$ua=LWP::UserAgent->new;
$response = $ua->request($request);
$session=$response->header("Set-Cookie");

[...] and later on:
my $header=HTTP::Headers->new;
$header->header('Set-Cookie' => $session);
my $request = HTTP::Request->new(GET => "http://www.hacker.org/runaway/index.php?name=$user&password=$password&path=$path",$header);
It's probably very similar in python... check the online doc :-)
virus171
Posts: 4
Joined: Sat Jul 10, 2010 1:54 pm
Location: Australia

Post by virus171 »

Thanks for your help. :) I'll see if I can get it working with this

EDIT: Thanks to your info, got it working! :D Now lets see how far i get with this basic solver
Post Reply