How does spider solitaire make sure that the game is winnable?

Hello! I’m working on a small spider solitaire clone
(Something like this)204816-spider-solitaire-7.png

Pretty much the whole mechanisms of the game is done, but I seem to struggle a bit (and by a bit I mean
A LOT) with the random card dealer mechanism. I the actual spider solitaire game, it makes sure that with the cards that it puts in your deck, you are able to win instead of just throwing random cards at you (at least that’s what I think), I was wondering how that works and how can I make something like that?
Any help would be appreciated, thanks! :smiley:

Hi, I made a similar game. I divide the cards in the deck into good cards and bad cards, based on the current situation. When player asks for a card, I can choose to give either a good or bad card, based on a luck percentage.