Why does the autocomplete feature on computer solitaire work?

658 views

[ad_1]

Isn’t it possible you can lose even after you’ve revealed every card because the order they’re in doesn’t allow you to put them away correctly?

In: Mathematics
[ad_2]

Yes, it is true that some games are unwinnable! However, many computer programs for playing solitaire have a special piece of code inside them that makes sure any game you’re presented with is winnable in some way, just to keep people who aren’t as aware as you are from feeling cheated. Plus, some programs might even figure out a solution before showing you the cards so that, even if you completely mess up, they can plot a route of undoing, redoing, and doing differently to get to the end.

Think of it this way: what is the next, smallest card that needs to be put on one of the target packs? That will necessarily be at the bottom of one of the rows, since all of those are strictly ordered in an ascending order. Put that card in its place. Now do this again and again until all the rows are gone at which point you solved the game. (Not sure about the correct terminology, hope it makes sense)

ELI12: Suppose you wanted to write a crude program to solve a game. What would you read to learn how to build this sort of project? Looking at introduction to optimization type material that kids into gaming may find useful.

Just like you can look at a solitaire game and say “If I play this card, then I can move that card and play what’s under that card…” and so on, a computer can do the same thing but many many times in a row, even 52 times! If the computer gets to a point where all the cards are gone in its mind (and it can’t do that if cards are still unrevealed), then the autocomplete happens, otherwise it won’t!