Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 207

Warning: preg_match(): Compilation failed: nothing to repeat at offset 1 in /home/tinyogre/rumsey.org/blog/wp-includes/class-wp.php on line 208
Ogre » Puzzle Quest Solver

Puzzle Quest Solver

I figure it’s not cheating when I use this program to solve Puzzle Quest capture puzzles. But if you use it, you’re totally cheating. I wrote the code, that means I solved the puzzle. You, you’re scum.
pqsolver.exe (Get this if you just want to run it)

pqsolver.cpp (Source code, if you want to see how it works or don’t trust random executables off the internet. Builds on Mac, Linux, Windows, probably anything else with a C++ compiler)

Sample input files:

test2.pq (not a real puzzle, just an early test)

OrcLord.pq (Real)

Sandworm.pq (Real)

To run it:

pqsolver < file.pq

The magic values, straight from the code:
case red: c = 'r'; break;
case yellow: c = 'y'; break;
case green: c = 'g'; break;
case blue: c = 'b'; break;
case skull: c = 's'; break;
case skullx5: c = '5'; break;
case xp: c = 'x'; break;
case money: c = 'm'; break;
case empty: c = '.'; break;

The output has the first step at the bottom, last step at the top. Backwards, in other words. Harder to do it the right way around the way the algorithm works. The bottommost board displayed is the initial input, the topmost is the next to last state before winning. Above each board are the coordinates to move to get to the next step.

Updated 11/09/2007 : Thanks to Nige in the comments, the bug with skulls is fixed.  You Rock, Nige!

25 Comments »

  1. AarnaK Said,

    April 7, 2007 @ 12:09 pm

    Hi,
    good program, but you can make a window interface. I’m also a programmer and like you understand the importance of a good interface! 😉

  2. Ogre Said,

    April 7, 2007 @ 12:16 pm

    The code is right there, feel free to make your own interface! A web interface would be great.

    Alternately, let’s say for the sake of argument that I’m willing to do contract work for a mere $75/hr. How much is that interface worth to you? :)

  3. Bob Said,

    April 14, 2007 @ 3:49 pm

    Ha! And I got yelled at by someone for commenting “the puzzles aren’t that hard” in a forum thread you made on this, cuz you are so nice and altruistic to provide this.

    Now we see your TRUE motives!

    On a serious note: I finally got stuck on one of these damn things, the Warg-rider. I’m resorting to your app shortly. :)

  4. someguy Said,

    April 15, 2007 @ 8:25 am

    Okay I’ve tried a depth first search now (obviously stopping when I run out of moves that do anything) and that takes more than the 5 minutes I’ve left it to run too. I guess I just suck 😉

  5. someguy Said,

    April 15, 2007 @ 8:28 am

    hm, I wish I knew how to edit posts. Well, it turns out that DOES complete in a few minutes, maybe Java really IS slow 😉 I think it’s more likely my code is just pretty suboptimal, copying grids is probably a good deal more expensive in Java, unless I do it with some kind of buffer.

  6. someguy Said,

    April 15, 2007 @ 8:48 am

    Ok the solution for orc lord is (with y counting up from the bottom, sorry that way made more sense to me, but the step order is still reversed as in your code):

    5, 0 to 6, 0
    2, 0 to 2, 1
    1, 1 to 2, 1
    1, 1 to 2, 1
    5, 2 to 6, 2
    5, 4 to 6, 4
    6, 2 to 7, 2
    1, 3 to 2, 3
    1, 2 to 2, 2
    0, 2 to 1, 2

  7. someguy Said,

    April 15, 2007 @ 8:48 am

    Sorry for all the posts… just to confirm, my Java implementation is much slower, so I’ll have to spruce it up a bit 😉

  8. Ogre Said,

    April 15, 2007 @ 6:07 pm

    Thanks for the note about the Ogre Lord. I’ll check it out when I get a chance.

    The number of copies my code does is indeed horrifying, I try not to think about it :)

  9. someguy Said,

    April 20, 2007 @ 2:30 pm

    Actually I typed Ogre Lord, but I meant Orc Lord, sorry 😉

  10. someguy Said,

    April 22, 2007 @ 3:28 pm

    Just in case anyone is following this, wolf rider solution is:

    6, 1 to 7, 1
    2, 0 to 3, 0
    1, 0 to 1, 1
    4, 0 to 5, 0
    4, 1 to 5, 1
    2, 2 to 3, 2
    2, 1 to 3, 1

    I’m so ashamed that I’m too stupid to work out the puzzles myself :(

  11. Risby Said,

    October 15, 2007 @ 3:37 am

    What do I need to run it? I downloaded the exe-file and opened it, had the OrcLord.pq in the same map and just wrote OrcLord.pq – the window closed and nothing happend.

    You need an FAQ to run shit like this.

  12. Hunny Said,

    October 26, 2007 @ 6:49 am

    Running this tool is simple – just pipe the data file (like OrcLord.pq) into the command.
    And if, by some occasion, you don’t know what “pipe… into” means – you need a book to learn shit like “computer”.

  13. Baz Said,

    October 29, 2007 @ 11:48 pm

    Fun little tool, compiles and runs fine for me. Only problem is there seems to be a bug in the way it explodes the +5 skulls. Step 3 (from the bottom) of its solution to the given Sandworm file has it explode a +5 skull. The following board has some extra greens and yellows that should have been destroyed in the blast (double checked in game that this is so).

    The Explode() routine seems to be correct from a cursory glance, but there’s probably a bug given some combination of row matching, exploding, and gem falling.

  14. Nige Said,

    November 7, 2007 @ 4:47 pm

    The comparison for the y loop in the Explode() function is wrong; there is a missing equals.
    It should read :

    for(y = yc -1; y

  15. Nige Said,

    November 7, 2007 @ 4:51 pm

    I’ll try that again

    for(y = yc -1; y <= yc + 1; y++)

  16. Ogre Said,

    November 9, 2007 @ 11:38 am

    Thanks, Nige! Source and executable have been updated.

  17. Arnar Æ Said,

    November 30, 2007 @ 3:18 am

    Hi

    I am trying to use the pqsolver with limited success.

    i use command prompt on Win XP and type
    “pqsolver sandworm.pq >>test.txt”

    but it stalls no error and does not stop until I break it.
    Any suggestions?

    Reg.
    Arnar Æ

  18. whoozle Said,

    December 2, 2007 @ 10:38 am

    troll.pq:

    ..g..g..
    ..rmrr..
    .gmgmmg.
    sgrxyrgs
    sybxbbys
    bbgmggbb
    syrxyrys
    syrmyrys

    consumes 100% cpu and hang for a long time :( I’ve successfully solved orclord,orcmage with pqsolver, thanks :)

  19. Morkatron Said,

    February 24, 2008 @ 2:13 pm

    I too am attempting to use the solver with no luck. I have typed “pqsolver sandworm.pq >>test.txt” at the cmd prompt and I receive the msg “the system cannot execute the specified program” Any suggestions?

    Thanks

  20. Morkatron Said,

    February 24, 2008 @ 2:14 pm

    Oh and I am using a XP pro OS corporate if that matters…

  21. Sumrnot Said,

    March 3, 2008 @ 8:18 pm

    Well, it’s nice to see someone else interested in writing a solver. I’m getting close to releasing a beta (exe only) myself.

    Featuring: (drum roll)
    – GUI (win 2000,nt,xp) uses MaskBlt Not sure about Vista.
    No Linux yet.
    – adaptive cache of about 140,000 positions
    – preemptive testing to cut down search space
    – animation (Dammit,Jim. I’m a programmer. not an artist)

    Give me about a week to track down some bugs and finish in-house, and if anyone’s interested I’ll post a link.

  22. Dave Said,

    May 6, 2008 @ 7:26 am

    Sumrnot, i’m really interested in your project, please post a link. Ogre’s code works perfectly, but it takes long time filling the text file.

    Thanks,

    Dave

  23. Raspa Said,

    May 28, 2008 @ 2:56 am

    Hey, I’m working on a solver aswell. I’m doing this on my freetime, so it might take a while. Currently I’m doing it in java, but maybe i’ll port it to processing to put it in a webpage.

    I’m still missing the handling of wildcards and 5xskuls, but if the problem doesn’t have neither, it finishes in about 1-2 seconds. (it doesn’t stop when the solution is found, so that’s the time to search all the solutions space)

    I’ll probaby finish the first version, this week or so, and i’ll share it to the world.

    Sumrnot, what do you mean by: adaptive cache of about 140,000 positions.

  24. puzzled Said,

    December 31, 2008 @ 1:29 pm

    Well, googling OGRE LORD brings you here… and there are solutions to other things…

    Might there be a solution for maybe…

    The Ogre Lord puzzle?

    ><

  25. facebook coupon app plr Said,

    January 5, 2014 @ 3:50 am

    After analysis a few of the weblog content on your web page now, and I truly like your way of writing a weblog. I stored it to my preserve web page history and will be confirming coming back soon. Pls analyze out my web page as well and let me know what you think.

RSS feed for comments on this post · TrackBack URI

Leave a Comment