Author |
Message |
bodjo

Joined: 26 Feb 2011 Posts: 37 Location: tunisia |
|
problem in automating the puzzle |
|
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 
|
|
Mon Jun 06, 2011 5:05 pm |
|
 |
uws8505
Joined: 23 Jan 2011 Posts: 32
|
|
|
|
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...
|
|
Mon Jun 06, 2011 5:18 pm |
|
 |
bodjo

Joined: 26 Feb 2011 Posts: 37 Location: tunisia |
|
|
|
yes but i want from the solver to automaticly do that
|
|
Mon Jun 06, 2011 5:24 pm |
|
 |
laz0r

Joined: 04 Feb 2010 Posts: 290 Location: Within the depths of Unix |
|
|
|
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. |
|
Mon Jun 06, 2011 5:49 pm |
|
 |
bodjo

Joined: 26 Feb 2011 Posts: 37 Location: tunisia |
|
|
Mon Jun 06, 2011 5:51 pm |
|
 |
virus171
Joined: 10 Jul 2010 Posts: 4 Location: Australia |
|
|
|
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
|
|
Wed Jun 08, 2011 11:42 am |
|
 |
MrTerry
Joined: 26 Jan 2010 Posts: 33
|
|
|
|
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? |
|
Wed Jun 08, 2011 9:58 pm |
|
 |
megabreit
Joined: 03 Jan 2009 Posts: 141
|
|
|
|
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 
|
|
Fri Jun 10, 2011 12:42 am |
|
 |
virus171
Joined: 10 Jul 2010 Posts: 4 Location: Australia |
|
|
|
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.
|
|
Fri Jun 10, 2011 5:13 am |
|
 |
megabreit
Joined: 03 Jan 2009 Posts: 141
|
|
|
|
I can tell you how this works in perl:
 |
 |
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 
|
|
Fri Jun 10, 2011 5:48 pm |
|
 |
virus171
Joined: 10 Jul 2010 Posts: 4 Location: Australia |
|
|
|
Thanks for your help. I'll see if I can get it working with this
EDIT: Thanks to your info, got it working! Now lets see how far i get with this basic solver
|
|
Sat Jun 11, 2011 2:39 am |
|
 |
|