# fc-solve / fc-solve / site / wml / src / faq.html.wml

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270``` ```#include '../template.wml' #include "xhtml/1.x/std/toc.wml"

I think I found a wrong move in the solution? What can I do?

While it is not unthinkable that Freecell Solver will have a bug and will make a wrong move, it is extremely unlikely that that is the case. Some people have reported that several multi-card moves are impossible, but as I demonstrated to them, they were in fact possible.

One can find the maximal number of cards that can be moved as a sequence in Freecell using the formula max_cards = (1 + num_vacant_freecells) * (2 ^ num_vacant_columns) (where “*” is multiplication and “^” is exponentiation.). One can also try using expand-solitaire-multi-cards-moves from the Games-Solitaire-Verify CPAN distribution (by the same author of Freecell Solver), in order to filter solutions and produce ones with multi-card moves expanded into many single-card moves. If you are on Microsoft Windows, you can install DWIM Perl and run it.

I think I found an abuse of Freecell Solver. What should I do?

We received a report or two about various people or companies distributing Freecell Solver along with their products, and the answer is that it is: 1. Likely legal, 2. We don't mind, and 3. We encourage commercial and/or proprietary use of the code or binaries.

Freecell Solver used to be distributed under the Public Domain, but was relicensed to the permissive MIT/X11 licence due to the problematic and not globally accepted nature of the Public Domain, especially in software. (See the page maintained by Rick Moen about it.) As far as we know (and this is not legal advice), the main legal and practical difference between the public domain and the X11 licence, is that one should keep attributing the original copyright holders as rightful holders (while the licence of derivative works may be changed into any other). As far as we are concerned, this is not something we want to enforce, but we still recommend to follow this, to stay on the safe side of the law.

So unless someone sues us for damages for a problem caused by the program or library (which violates the no warrany paragraph of the licence) everything should be fine and the “abuse” of the program is acceptable.

What are the uses of a solver for Patience, such as Freecell Solver?

Freecell Solver is unlikely to help in curing cancer, or solve world hunger, but it still has some uses. One use is determining whether an initial layout of a game, or a layout in mid-play is solvable or not so a human player can know whether he needs to return to an earlier position. The default configuration of Freecell solver may still report a small number of solvable positions as unsolved, but that can be mitigated by passing some command-line flags.

Another use of a Solitaire solver is to find solutions for difficult deals, or attempt to find shorter solutions. Yet another use is to collect statistics from a large number of random deals (say, the Microsoft Windows Freecell deals or PySolFC’s deals), which is part of what Freecell researchers do.

The Freecell implementation for Windows, Freecell 3D has also introduced a “Race against the computer” mode of Freecell, which is an interesting challenge.

Finally, we have more recently started to investigate some “human/computer collaborated” Freecell solving, where a human aided by a Solitaire suite with good solver integration can attempt to solve some difficult deals (for both a human and a computerised solver), by pruning dead ends, and by finding whether reached states are solvable. This provides a combined solving power, that is greater than the sum of both parts.

I Started Writing a Freecell Solver (of my own) but it is too slow. What can I do?

The problem with many naïve Freecell solving solutions is that, while they can succeed in solving many Freecell deals, they may fail spectacularly in the general case. Furthermore, Generalised Freecell (where there is an arbitrary number of ranks) was shown to be an NP-complete problem and as a result, it is unlikely that no efficient solution for solving that can be found.

You can try inspecting the code of Freecell Solver or one of the other solvers for insights, but note that their code (and especially Freecell Solver's) may be somewhat complex, and hard to understand for people with relatively little experience. You can also pursue some of the Freecell Solver documentation as well as the archives of the fc-solve-discuss mailing list for some insights and ideas.

Here is some general tips:

• Make sure that the positions in the graph of the game are represented as a single segment of memory (normally a C struct) and can be compared for equivalence easily (using memcmp() or a similar function).

• Use an efficient data structure to hold the states in the collection such as a hash table or a self-balancing binary tree.

• Often randomising the solution (see Freecell Solver's Random-DFS scan which was inspired by a different solver called Freecell Tool can help a lot).

• Freecell Solver makes heavy use of switch tasking: having several different searches operate on the same board, until the first search yields a solution. This normally yields a solution quicker than a singular scan.

• Consider implementing moves as meta-moves: sequences of several single-card and/or sequence moves that implement a certain ends. This can yield a solution faster than using single-card moves (also known as atomic moves).

Finally, note that we could use a helping hand with Freecell Solver, and the authors of other open-source solvers may be happy for help as well, so if you want to improve something more mature, then contact us.

May I integrate Freecell Solver into my program? If so - how?

Yes, you can, as long as you accept the MIT/X11 licence . We also would appreciate an acknowledgement and a link to the Freecell Solver home page, in the About Dialogue, and in other places.

Now regarding how to integrate: please either use the freecell_solver_user_* API, or alternatively parse the output of fc-solve with the -p -t -sam -sel flags. The freecell_solver_user_* API is not documented at the moment, but should be self-explanatory, and there are some examples of using it in the various solvers in the distribution. One useful way to configure a solver handle is to use fcs_cl.h which provides an API based on the Freecell Solver command-line and is more convenient than issuing multiple lower-level API calls.

You can opt to put the solver on a separate thread, on a separate process, or alternatively limit the iterations and increase it constantly, in a pre-emptive multi-tasking fashion.

Good luck and let us know if you run into any trouble, or, alternatively, if you are successful.

The Solutions I Got are Too Long. What can I do?

You can try using a flares-based preset such as qualified-seed and optionally add --flares-choice fcpro and -fif 10, where 10 can be replaced by a larger (or smaller) number. So the complete command would be:

pi-make-microsoft-freecell-board -t 24 | \     fc-solve -l qs --flares-choice fcpro -fif 10 -

If this still does not work to your satisfaction, you can try constructing a specialised heuristic from the many command line options of Freecell Solver that will yield something. There are some examples for those in the individual flares and soft threads under the Presets/presets directory.

Why is Freecell Solver written in C? Why not in another language?

Part of the reason why Freecell Solver is written in C, is because the first released version (version 0.2) was written in C, and it continued to be maintained in this language. Other reasons are:

• C is fast and memory efficient.

• C is portable.

• The bit-handling operators of C are utilised extensively in the Freecell Solver source.

• As opposed to C++, C is easier to get right, is more of a “no-nonsense language”, is less hyped, and does not encourage crazy or pointless practices. Also see what I’ve written about it previously.

I found a solvable deal that Freecell Solver reports as Unsolvable - should I report it to you?

The default Freecell Solver heuristic may have a small number of deals that are reported as unsolvable despite being solvable. However, you can use scans based on atomic moves to rectify that. See fc-solve --help-configs and the USAGE.html file for more information.

```