Sokoban Solution

Stuck at a level? Need help with R'n'D or anything R'n'D related? Post here!

Moderators: Zomis, Flumminator

Post Reply
edb
Posts: 3
Joined: Wed Dec 13, 2006 2:24 am

Sokoban Solution

Post by edb » Wed Oct 30, 2013 4:03 am

I read in a change log entry dated 2010-03-27 that says RnD now supports Sokoban solutions in native 'udlrUDLR' format.

I created a text file with a UDLR sequence string (one long string w/ no embedded control chars or EOLs), named the file as "011.sln" (the level I wanted), put it in my sokoban tape directory, yet I cannot find a way to get RnD to recognize or play the file.

I'm using RnD version 3.3.0.1

Suggestions?
Pointers?

Thanks in advance.

Anonycat
Posts: 39
Joined: Thu Mar 27, 2008 4:45 am

Re: Sokoban Solution

Post by Anonycat » Wed Oct 30, 2013 6:13 am

The problem arises in libgame/setup.c: there are two similar functions that attempt to get the file name of a solution tape from a level number. getTapeFilename() only checks for the ".tape" extension, while getSolutionTapeFilename() also looks for .tape but considers .sln files if they exist. The two functions are called, respectively, by LoadTape() and LoadSolutionTape() in files.c, and it turns out that there are only two places in which LoadSolutionTape() is called: when using :ist at the main screen, or when running the game in autoplay mode to verify the correctness of all the :ist tapes.

In both situations, the only use case that the game anticipates for .sln files is if they're placed in a "tapes" subdirectory under the level directory itself, not in your general saved tapes folder. Anything that looks in there will only call LoadTape(), and refuse to consider the possibility of a hand-crafted .sln file in place of a tape, because RnD doesn't export to that format, and the "tape" couldn't possibly be something you recorded by playing the game.

User avatar
Holger
Site Admin
Posts: 3225
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: Sokoban Solution

Post by Holger » Wed Oct 30, 2013 8:19 pm

Perfect description -- thanks Anonycat!

So to summarize how to play that solution tape you created: Put it into the folder "levels/<levelset>/tapes" (where <levelset> is the folder name of the level set with your Sokoban levels, and where the "tapes" sub-folder may need to be created, if it not exists), start R'n'D and, in the main menu, blindly type ":ist", which is a "cheat mode" key shortcut for "insert solution tape". (If R'n'D displays an already existing tape, unload it with the "eject" button before typing ":ist"!)

The logic with LoadTape() and LoadSolutionTape() is used to keep the solution tapes a bit "hidden" behind the normal tapes recorded by the user, and to require at least a little bit of active cheating to spoil... ;-)

BTW: I'm thinking of adding a third kind of tapes which contain "demo tapes" (maybe stored in a "demos" sub-directory) which could be played automatically after some time of idling in the main menu. If I remember right, both Boulder Dash and Supaplex did this, so it might be a nice addition...

filbo
Posts: 358
Joined: Fri Jun 20, 2014 10:06 am

Re: Sokoban Solution

Post by filbo » Thu Jul 10, 2014 11:12 am

I'm thinking of adding a third kind of tapes which contain "demo tapes" (maybe stored in a "demos" sub-directory) which could be played automatically after some time of idling in the main menu.
I sometimes move files around in my tapes directories, e.g. in ~/.rocksndiamonds/tapes I have files rnd_niko_boehm/025.tape.{blue,green,red,yellow} and rnd_richard_kleber/006.tape.{blue,green,red,yellow} -- these are levels where you must choose which single one of four keys to pick up, then the rest of the level is guided by which key you have.

I have sometimes wished that RnD would notice these "%03d.tape.%s" sub-tapes and offer to do something with them (e.g. ask: which one do I want to load?).

For demos, you could have whatever.tape.demo in the regular solution tape hierarchy.

But why are special "demo" tapes necessary? If the idea is to show something interesting without completely solving levels, you could probably do that automatically from existing solution tapes.

Start the tape normally, but introduce a small chance of mis-following the instructions, e.g. at time N% of the tape, some chance (like N / 1000) that you will move the player in the opposite direction as the tape says. Except for super-short levels, this should ensure that no demo will live to the end. Anyway, just fade out when the tape gets to 50%. Those two tweaks should give many tantalizing hints for levels, without generally giving them away.

Would there still be a reason for actual demo tapes? Maybe -- you could show off various silly things that players wouldn't normally do. But a nice "attract mode" can certainly be made without the extra effort of creating a body of special "attract" demos.

Post Reply