# Saved Solutions

Solution are preserved in a user description file (file with extension .sokoinfo).

The main reason to preserve them is not to play some level twice if one has already solved it. There are lot of levels (currently I know for more than 10000) and there are lot of collections with mixture of levels. With this feature one can easily see whether this level was already solved by him. In case it was solved solution statistics are shown in bottom right corner of a window (right on status bar). If there are more than one solution preserved for that level then right box becomes combo box and player can select different solutions for replay.

YSokoban has a database to remember any level that the player has solved. If you load a level that you've solved before, regardless if it was in a different orientation (rotated/mirrored), YSokoban will be able to point out that it was solved and you can replay the solution. If a level was solved by the player before, YSokoban will tell you so via the box in the bottom-right corner by providing score for the level.

## Set number of preserved solutions

In this dialog (activated from menu) one can set maximum number of different solutions preserved for each category.

## Normalized levels

Level is recognized even if it rotated or mirrored or in some cases where some walls are added or removed but do not change level. In fact YSokoban compares normalized level, not the real one. YSokoban stores internally (with solution) levels in normalized state. Normalized level is called a level which could be a little bit different than normal level. There are several rules which are applied to normalize level.

### All non reachable cells are replaced with walls

If some cell is not reachable then it is of no interest at all and could be replaced by wall. Two levels which are different only in that one of them have and the other one doesn't have wall at that cell are in fact equal. For example all cells marked with '-' are in fact unreachable and thus replaced with walls in normalized form:

    ###----             #######
    #  ##--             #  ####
    #  $.##             #  $.##
    # ###--    --->     # #####
    # #-#--             # #####
    # #####             # #####
    #   @ #             #   @ #
    #######             #######

### Dead end tunnels are filled with walls

Dead end tunnels are of no use, because man can not push box there (or more precise - shall not push box there) and even if man goes inside then it shall go out without doing something meaningful. If man is initially inside such a tunnel then it is forcibly moved out of it (if in such case it has to push a box, then box is forcibly pushed). For example:

    #######             #######
    #  ####             #  ####
    #  $.##             #@ $.##
    #-#####             #######
    #-#####    --->     #######
    #-#####             #######
    #---@-#             #######
    #######             #######

### Dead locked boxes are converted to walls

Dead locked boxes (on target) are boxes which are not possible to move. For example:

    ######              ######
    # $. #              # $. #
    # ** #    --->      # ## #
    # ** #              # ## #
    #  @ #              #  @ #
    ######              ######

### Normalized level

Applying several times this rules level is changed and sometimes is hardly recognized as the starting one (even without rotation), but this is something one shall not think of. Important thing is that YSokoban tries to find whether level is equal to some already solved level and if so to notify player (showing solution statistics). Same approach is used in SokoDUP to find duplicate levels.

### Trivial levels

Trivial levels are levels which are solved only by using forced moves/pushes, there is one and only one way for the man to move at all and at the end all boxes are pushed to targets.

Trivial levels will be indicated in the bottom-right corner box (statistics info) as "trivial".

YSokoban does not preserve solution for trivial levels.

For example following level is trivial:

    ##### forced    #####  rule3  #####
    #@$.# ------>   ##@*#  ---->  ##@##
    #####           #####         #####

In this example, first a forced move is applied (man is inside dead end tunnel). Then unmovable box is converted to wall and we get a lonely man in a room (seems like man in jail). So there is nothing to do and this is trivial level. Here is another example of trivial level (not so obvious, but trivial again):

      ###         ###         ###         ###         ###         ###
    ###.##      ###.##      ###.##      ###.##      ###*##      ######
    #.$$.#      #.$$*#      #.$$##      #.$$##      #.$@##      #.$@##
    ##.$$# ---> ##.$@# ---> ##.$@# ---> ##*@## ---> ###### ---> ######
     ###@#       #####       #####      #####       #####        #####
       ###         ###         ###      ###         ###            ###

Created with Ywiki